Skip to main content
Lewis Manaton a posé une question dans #Data Management
Hi there,

 

Just a quick question im sure someone can answer.

 

I have a number of custom buttons on my Lead page, depending on the lead i use them to automatically send an specific email template, it seems to work fine.

 

However, what i need it to do is also update the Description field in a task to say a certain email has been sent. On the button click I just wanted it to add a new line of text to the existing descption saying the [DATE/TIME] - [USER] - [Name Of Email Sent].

 

It all happens on a button click so im sure i can add some custom javascript in to do it but im kinda drawing a blank as to how to accomplish this.

 

Any Help would be appreciated :)

 

Many Thanks.
14 réponses
  1. 18 avr. 2013, 16:42
    Hi Lewis,

     

    Here is the code. I tested it on my Dev Box and it does what you want. Please try it and get to me soon.

     

    {!REQUIRESCRIPT('/soap/ajax/27.0/connection.js')}

     

    var event = sforce.connection.query("SELECT ID, Description FROM Event WHERE WhoId = '{!

    Lead.Id

    }' LIMIT 1");

     

    var currentDate = new Date();

    var day = currentDate.getDate();

    var month = currentDate.getMonth() + 1;

    var year = currentDate.getFullYear();

     

    if(event. done =='true' && event. size ==1){

    var modEvent = new sforce.SObject('Event');

    modEvent. Id = event. records . Id ;

    modEvent. Description = '';

     

     

    if(event. records . Description !=null){

    modEvent.Description = event. records . Description ;

    }

     

     

    modEvent. Description += '\r\nNote: [' + day + '-' + month + '-' + year + '] [{!$User.FirstName} {!$User.LastName}] <Name-of-the-Mail-Sent>';

     

    var result = sforce.connection.update([modEvent]);

     

    if(result[0]. success =='true'){

    alert('The Event has been Updated Successfully.');

    }

    }

     

     

    Regards,

     

    Deepak
0/9000