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
RossGRossG 

Is it possible to programmatically add a new record to a custom object when a picklist value is added to a picklist field on another object?

I don't think this is possible but wanted to check with the community to see if anyone has had this use case before.  Thanks
Best Answer chosen by RossG
kevin Carotherskevin Carothers
Hi Ross

It does get a little tricky...

In some instances, adding an object if you are modifying a "setup" object (like; modifying a User record) can cause a "Mixed DML" error.


Can you post some code?

All Answers

kevin Carotherskevin Carothers
Hi Ross

It does get a little tricky...

In some instances, adding an object if you are modifying a "setup" object (like; modifying a User record) can cause a "Mixed DML" error.


Can you post some code?

This was selected as the best answer
RossGRossG
Hey Kevin, thanks.  Actually this is related to the work you were helping with on another discussion.  Turns out I found a way to clean up the code to get around this issue, so for me now, this is no longer an issue.  The issue was my code was doing more than it needed to I think.  

But I'd still like to know if this is even possible.  

Basically the idea is this:

I have 2 objects, "A" and "B".
I have a picklist on object A with say 3 values: e,f,g.
Let's say I add a new value to that picklist in object A called "h"
When that happens, I want SF to programmatically insert a new record on object "B", with say a name "h".

I don't see how I trigger could do this since we're talking about adding a new piece of metadata, and not actual data, but, maybe it's possible and I don't know how.  Just curious I think.