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
flewellsflewells 

Can an Apex trigger do this?

Hi there, I have a need to automatically maintain a field (multi-select picklist) that I cannot accomplish using workflow.  More specifically...

 

  • I have my Account object.  On Account, I have a multi-select picklist field.
  • I have my Custom object.  On the custom object, I have a lookup to Account.
  • When I enter an Account on my custom object record, I want to take information from the custom object record and automatically update the multi-select picklist field on its related Account.  Because an Account can be related to multiple custom object records, I need this information to update the multi-select picklist, but not overwrite any existing values.

Is this possible with an Apex Trigger?  If yes, is it also possible to remove a specific value from the multi-select picklist if I removed the Account from the custom object?

Any comments or tips are greatly appreciated!
Anand@SAASAnand@SAAS
Yes, you can acheive this using a trigger. however you will need to keep in mind concurrency issues. For e.g. if two users are updating two different custom objects that are related to the same account, it's possible one of the operations may overwrite the multiselect values that the other transaction updated.
flewellsflewells
Thanks for the reply and heads-up re: the concurrency issue.