Is there a way to auto-populate the NPSP Primary Contact lookup on the Opportunity? - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Nicolle BennettNicolle Bennett 

Is there a way to auto-populate the NPSP Primary Contact lookup on the Opportunity?

Hello,

I would like to auto-populate the Primary Contact lookup field on the opportunity with the "Created By" field (in our case, opportunity records are created from a partner user portal). I want to auto-populate this field so that I can take advantage of the NPSP setting that will auto-create the contact listed in the Primary Contact field as a campaign member. (I don't necessarily need to populate contact roles on the opportunity, though if I do in the process it's fine). I've tried using process builder to populate the field, but I receive an error every time. I imagine there is something happening on the backend with NPSP that I am unaware of. Any guidance would be appreciated!
Best Answer chosen by Nicolle Bennett
Tom HoffmanTom Hoffman
You might be populating a lookup to a Contact record (primary contact) by referening a User Record (created by).  

On your field update, select opportunity, created by id, and then the contact id field.  This contact id field is only populated for partner or customer community users. 

You'll also wanto add some criteria to process flow, one that says (in addition to your other criteria) to only fire when Opportunity.CreatedBy.ContactId <> null.  Just to prevent this from firing for standard users and potentially getting an error from there as well.  

User-added image

All Answers

Tom HoffmanTom Hoffman
You might be populating a lookup to a Contact record (primary contact) by referening a User Record (created by).  

On your field update, select opportunity, created by id, and then the contact id field.  This contact id field is only populated for partner or customer community users. 

You'll also wanto add some criteria to process flow, one that says (in addition to your other criteria) to only fire when Opportunity.CreatedBy.ContactId <> null.  Just to prevent this from firing for standard users and potentially getting an error from there as well.  

User-added image
This was selected as the best answer
Nicolle BennettNicolle Bennett
Apologies for the delay in my response - thank you so much for your help!
Nicolle BennettNicolle Bennett
I have a follow-up question for Tom (or anyone) - this process is now working great. Now, when an opportunity is created via the portal, the Primary Contact field (as well as Contact role) are populated by the Created by field. I've activated the NPSP setting that auto-adds a campaign member to any campaign with the Primary Contact and Primary Campaign Source fields filled in - though the setting is not working as expected, and the primary contact is not getting added to the campaign. I'm guessing it is because I am filling in the Primary Contact field with a process builder, instead of manually. Is there a workaround that anyone can think of? Can I possibly alter the trigger handler for that NPSP trigger somehow? Thanks again for your help!
Tom HoffmanTom Hoffman
Not sure the reason its not working for you.  If the box is checked in NPSP settings, primary contact provided, and a primary source identified, that should fire appropriately.  

If for some reason or another that refuses to work, you could turn off that setting and then use PB again.  So the criteria for the PB would be:
Primary Contact<>null and Primary Source <> null (be sure to check the box under the 'Advanced' section so this PB flow only runs when criteria is met otherwise, you run the risk of indtroducing duplicates with each edit/save), followed by a create a record action that creates your 'campaign member' record.