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
xnerd00xxnerd00x 

Need to create child record to User object

Hi all,

We have a requirement at our company to add a related list to the delivered user object. However,salesforce doesn't allow the user object to have a related list.  So we decided to create a new custom object called user_default that link back to the regular user object.

 

However, when we tried to create the user_default object after insert into the user table, salesforce gave us an error saying that any change to the user set-up object cannot be accompanied by an insert/update to a non-setup object.  Soooo... we decided to have a link on the page that would take the user to a 'new' user default page with their user id auto-filled in IF the row did not exist already.  If it did exist, we would like to take them to the already created page.

 

Being new to salesforce, I'm not quite sure how to do this.  I'm thinking I need a SOQL statement to query the user_default object to see whether that user_id exists, and if so, then build the link appropriately.  However, I don't see how you can execute a SOQL query within the link.  I know you can make an apex call, but according to what I've read, you can only return a success/failure from it (I would need the user_default Id returned).

 

Any ideas on how to do this?  Is my approach even viable?  Or is there a different approach I can take?

 

p.s. VisualForce pages are currently not in scope for our project, so non-VF solutions would be appreciated, but that doesn't mean to not respond if a VF solution is all that's available.

 

Thanks in advance.