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

Trigger Help!!!

Hi Folks
Huge Huge favour to ask. Im strugglin with a trigger and just wanted to see if you could help perfect it?

It should be everytime a Contact is updated or inserted you check the DRM Active flag. 
If its true you assign the DRM Contact Employer as the Primary Account.
The Primary account will be whatever Account the DRM Contact Employer is. 

Ive tried this Is this anywhere close?

trigger PrimaryAccount on Account (before update, before insert) { 
//Set of Account Ids 
 for(Account fcon : Trigger.New)
    if(fcon.DRM_Active_c != TRUE)
        fcon.DRM_Contact_employer = fcon.ParentId;

Other criteria is:
Ensure this field isn't visible to standard users
Ensure this field is wiped if their employment history is deleted or if all records are set to inactive.

Any help would be Greatly appreciated. 

Himanshu ParasharHimanshu Parashar

You are doing absolutely fine. but I have few questions for your criteria.

1. Are you hiding fields from layout only ?
2. when you say employment history. is it referring a custom object if yes you need to do a soql everytime your update that flag.

Salesforce Certified Developer | Administrator | Service Cloud Consultant

P.S. If my answer helps you to solve your problem please mark it as best answer.
Hi Himanshu
here aree my answers
1. Yes
2. Yes. How do I run a Soql query?