Posts

Showing posts with the label developer

Trigger to update latest due date of task on Opportunity

Create a new custom field on opportunity called  Update_Due_Date_of_Task__c (Date/Time) and create the below trigger on task object.  Output : If there are multiple tasks on opportunity the above custom field will be updated by due date which is greater from all task's due date. Trigger updateLastActvtyUpdateOnOpty on Task(after update, after insert) {     Datetime lastUpdatedDate;     Set < String > whatIDs = new Set < String > ();     for (Task tskObj: Trigger.new) {         if (tskObj.whatId != null && tskObj.ActivityDate != null) {             whatIDs.add(tskObj.whatId);         } ...

Custom Button to take Ownership for Case Record

Create a new Detail Button on the Case object. Set Behavior to Execute JavaScript and Content Source to OnClick JavaScript Paste the Below snippet of code in the window  {!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}  var caseObj = new sforce.SObject("Case");  caseObj.Id = '{!Case.Id}';  caseObj.OwnerId = '{!$User.Id}';  var result = sforce.connection.update([caseObj]);  if (result[0].success=='false') {  alert(result[0].errors.message);  }  else {  href= "https://cs16.salesforce.com/ui/support/servicedesk/ServiceDeskPage#/{!Case.Id}" ;  // return to console document.location.reload(true)               // Refresh the Tab } Note : Change the return URL    to Current URL. Enjoy Coding !!