0

Hi I am an admin not a developer but my boss asked this request and I am reaching out for help.

On the contact object I have a field named S_Rapport__c and it is a user lookup field. There is also a field S_Rapport_inactive__c that is a formula field, if the user is active then it populates Active. Then I have a field named S_Caller__c that is a user lookup.

I need the trigger to: If S_Caller__c is blank then populate the field with the value in S_Rapport__c as long as S_Rapport_inactive__c equals Active.

Any help is appreciated. Thanks!

1
  • 1
    Have you made any attempts yet? There is a ton of info out there that should help you get started. Try googling trigger to update a user lookup field and if you get stuck, come back and post your code and where you are getting stuck. This link is to a similar question her on the stack exchange: salesforce.stackexchange.com/questions/23298/… – Jenny B Sep 25 '14 at 16:16
1

Welcome to SFSE. If you are new to SalesForce development then the SalesForce Workbooks are a great place to start learning how to develop in Apex.

The code below should do what you are looking for but have a look at the workbooks as well.

trigger ContactBeforeTrigger on Contact (before insert, before update) {
    for (Contact c : Trigger.new) {
        if (c.S_Caller__c == null && c.S_Rapport_inactive__c == 'Active') {
            c.S_Caller__c = c.S_Rapport__c;
        }
    }
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.