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
ChrisSargentChrisSargent 

Triggers to make a Related List Required

Hello,

 

I haven't used Triggers before and before I go down the path of learning them in depth I'd like to know if they could actually achieve what I'm looking to to. Essentially, in several areas of Salesforce we have records that are linked to other records via junction objects. I would like to make the creation of these junction objects required before the 'owing object' is saved.

 

For example, I notice in standard salesforce, you have the related list on cases called case comments. If it's possible to write a trigger that would require a user to add a case comment to any case they create (otherwise the case will not save / will be deleted) then probably I can achieve what I want....

 

Any help / advice would be much appreciated....

 

Thanks!

 

Chris

bob_buzzardbob_buzzard

I don't think you can do this using triggers, as you are trying to make the user do something that requires the parent case record to be present - adding a comment - before they can save the case.  This is more of a job for Visualforce, in that you could make the user fill in both the parent and child information before allowing them to commit their changes.

ChrisSargentChrisSargent
Yeah, this is what I've thought too.... using triggers, I could automatically create a case comment but only with pre-populated fields rather than prompting the user to put in more information.