function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ckellieckellie 

Mass Attach Content

Does anyone know of a way to mass attach documents that are in content to multiple accounts?

 

Thanks,

ckellie

sridivyasridivya

hi ckellie,

 

follow the steps to mass attach to multiple accounts,

 

Step 1:-

 .

 

global class MassNoteInsert{

 

  WebService static Integer insertNotes(String iTitle,

                                       String iBody,

                                       Id[] iParentIds) {

    Note[] notes = new Note[0];

    iBody = String.escapeSingleQuotes(iBody);

    for (Id iParentId : iParentIds) {

        notes.add(new Note(parentId = iParentId,

                           title = iTitle, body = iBody));

    }

    insert notes; //Bulk Insert 

 

    return notes.size();

  }}

 

Create that class.

 

Then

 

Step:2

 

 

SetupàappsetupàcoustomiseàAccountàButton&linkàcreate new

 

Select following

 

Button type:list button

 

Required javascript

 

Onclick

 

 

Then paste this code

 

{!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/14.0/apex.js")}
 
 
var idsToInsert= {!GETRECORDIDS( $ObjectType.Account )};
var noteTitle = prompt("Please enter the title of the note");
var noteBody = prompt("Please enter the body of the note");
 
if (idsToInsert.length) {
 
   // Now make a synchronous call to the Apex Web service
   // method
   var result = sforce.apex.execute(
    "MassNoteInsert",       // class
    "insertNotes",          // method
    {iTitle : noteTitle,    // method arguments
     iBody: noteBody,
     iParentIds: idsToInsert });
 
   alert(result[0] + " notes inserted!"); //response
} else if (idsToInsert.length == 0) {
   alert("Please select the accounts to which" +
         " you would like to add notes.");
}

 

 

Then save

 

 

Step 3:-

 

 

Goto Account search layout add new button to Account page.

 

 

Then click on Account tab u can find button on Account page by using that we can add mass notes to selected Accounts.

 

ckellieckellie

Thank you for the code, but I am looking to mass attach content from my content library. Is there any way to do that?

 

Thank you