+ Start a Discussion
Ad.baylesAd.bayles 

Help with Trigger - Create entitlement on Account update

Hello,

I am trying to write a simple apex trigger on Account, which will be fired on account update. The trigger will create an Entitlement.

This entitlement should be linked to an Entitlement process defined by default (always the same)

 

I don't get any error with this code, but the trigger does not create anything ^^

 

trigger CreateEntitlement on Account (after update) {

List<Entitlement> createentitlement = new List <Entitlement> {};

for (Account acc : trigger.new) {

if (acc.VAT__c == '1') /* If the Account custom field VAT__c = 1 */

{
createentitlement.add(new Entitlement (
Name = 'OK' /* Give a standard name*/
AccountId = acc.Id, /* Link the Entitlement to the account */
SlaProcessId = '552M00000004CAu' /* Link it to a defined entitlement process */
));
}
}
try {
insert createentitlement ;
}
catch (Exception Ex)
{
system.debug(Ex);
}
}



 

Any suggestion ?

Best Answer chosen by Admin (Salesforce Developers) 
Ad.baylesAd.bayles

Oh actually my Trigger works fine ;)

 

Thank you all for your help ^^