1

Is it possible to populate a lookup field with Process builder when it is creating a record?

A NPR record must be created by the process builder if the Contract status changes to a certain value.

The process should be like this:

The Contract status changes -> an NPR record is created (the NPR is linked to a Project record). I want to populate the Project Lookup on the NPR with a value coming from Contact-> Opportunity -> Project.

I tried using the record id field, Project Name, a custom text field on the Project that contains the id from the project ... but I keep getting an error:

"You encountered some errors when trying to save this record We can't save this record because the “NPR - create new NPR based on Contract Status” process failed. Give your Salesforce admin these details. This error occurred when the flow tried to create records: FIELD_INTEGRITY_EXCEPTION: Project Name: id value of incorrect type: a0H2a0000042BkgEAE. You can look up ExceptionCode values in the SOAP API Developer Guide. Error ID: 1360218809-19989 (688504257)"

Did I do something wrong?

  • 2
    The error states that an id with prefix a0H is not the proper key prefix of whatever lookup field you are trying to populate. That said, stuffing id values into text fields is not best practice. Instead, your PB should delegate work to Flow for record creation as Flow can do queries to find related records – cropredy Feb 26 at 16:33
0

From the hierarchy mentioned in your question, it seems Process builder alone will not be enough to fetch the Project lookup for you, since you will need to go back to Contact --> Opportunity --> Project to get that which will require querying the data (as mentioned in the comments by @cropredy)

A typical flow (algorithm) would be

  1. trigger the Process Builder upon contact update, as you are already doing, and leave the Project lookup blank.
  2. Add another action flow and create an autolaunch flow
  3. set input variables in the flow, which will be the contact Id coming from Process builder and NPR variable also from Process builder.
  4. Query related records (honestly, I am not able to clearly understand the hierarchy here) and fetch desired `ProjectId'
  5. Set Project lookup with the Id fetched from above step to NPR variable
  6. Update NPR
| improve this answer | |
0

You can use Process Builder but you cannot use an Immediate action. The record has to be saved first since you are using a lookup field. If you make the action a scheduled action and use "0 Hrs after last modified date" that will get you as close to immediate as you can get. This allows the record to save and then populate the lookup field you reference.

You can then use a Create Record action in that Scheduled node and be able to use the Relatcionship picker to get where you want to Opportunity and then Project.

| improve this answer | |

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.