I have two objects - one is the Opportunity and the other one is a custom Object. There is a lookup field from the Opportunity to the Custom object, but also from the Custom Object to the Opportunity. The look-ups are not being populated, unless I am building triggers to do so.

The custom Object holds the product lines triggered from another system. For one Opportunity in Salesforce, there can be up to 2 Orders in the other system. When the product lines are coming back to Salesforce, they are coming back as separate lines, referencing the different Order numbers (custom field 1 on the related records will have a different Order Number). There is also a custom field on the custom object that determines if the Orders are related to the same Opportunity.

I want to be able to reference different values from the custom Object on the Opportunity Page without the need to create too many triggers:

  1. Default Order Number
  2. Second Order Number, if applicable. (there is a checkbox on the custom object and if the related records belong to the second order, the checkbox = TRUE)
  3. Change pick-list value on the Opportunity, based on the values of a field on the related records from the custom Object.

What I have tried so far:

  • Trigger to populate the order numbers from the other system - in two separate fields on the Opportunity in Salesforce (custom field a and custom field b)

  • PB on the custom object - to change the pick-list values, but the process fails when trying to check if the related records are related to the same Opportunity number in Salesforce), if the lookup field is not populated, so I have tried to create a trigger to populate the lookup with the id of one of the related record, for the process not to fail and created the custom field a and custom field b as formula fields, instead of using trigger.

    Custom field 1:
    IF(Custom_Object__r.Check_Box__c = FALSE, Custom_Object__r.custom_fielda__c, null)

    Custom field 2: IF(Custom_Object__r.Check_Box__c = TRUE, Custom_Object__r.custom_fieldb__c, null)

But it doesn't fulfill the requirement, because the Opportunity in Salesforce, will always have a default order from the other system that I want to show on the Opportunity, so depending what id I am filling in the lookup, the formula doesn't always populate the default order number. The second order number needs to be populated only if there are related records with checkbox = True.

Any help will be appreciated on how it's best to achieve the requirements.

Thanks a lot.


I am not sure I completely understood your requirement, but what you could perhaps try is to create a "containing" Custom Object which would hold the values for both Order Numbers, and associate that one with the Opportunity instead. That way, you could always ensure that the Order Numbers are associated to the same Opportunity when they are inserted, and that would simplify the Process Builder that you were trying to create.

| improve this answer | |
  • Hi, Thanks for coming back to me. Yes, sorry. Tried to summarized it as much as possible. Not sure if it makes more sense now. – SSimion Dec 17 '19 at 14:35

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.