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
evgenykaevgenyka 

Need help on two triggers

I am familiar with php and new to apex code.

 

I need some help creating 2 triggers.

 

1)     Every time when caseupdated and field  XXM__C or XXM1__C orXXM2_C is changed I would like to set field FLAG__C on cases to null

2)     Every time attachment uploadedto case that field FLAG__C on this case is set to true I would like to update anew object  called ATT_HISTORY and set ATT_HISTORY.attachment_id to Attachments.attachment_id and ATT_HISTORY .FLAG__C  to 1

 

P.S if I can add custom field on attchemnts object (which I couldn’tdo in application) then I prefer in question 2 this custom field called FLAG__Cand set it to 1

BritishBoyinDCBritishBoyinDC

Re point 1, you should really try and do that via workflow if you can - there is an ischanged() formula you can use to evaluate the rule... if you really want to do via apex, just look for the examples in the apex docs about using trigger.old - there are several...

 

I am not sure you can do 2 that easily though - to my knowledge, you can't add field to the attachment object, and there aren't triggers on that object either...

evgenykaevgenyka

Thank You for the first one, this will work fine for me.

Is there any possible solution on the second one?