-1

Apex code to create a record picklist in an object when a new member is created in another object?

1 Answers1

0

Picklist value sets cannot be mutated directly in Apex. You would have to make a callout to the Metadata or Tooling APIs in order to achieve this, which cannot be done in a trigger, so you'd have to use Asynchronous Apex.

Making automated changes to metadata is a complex and somewhat risky implementation. Because the running user of the trigger in many cases will not have permission to call those APIs at all, you'll likely have to use a Named Credential-based approach to authorize as a specific System Administrator.

This implementation does have security considerations and involves a lot of complexities and considerations around change management. It should be carefully considered by the org's architecture stakeholders.

David Reed
  • 2,522
  • 2
  • 16
  • 16