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
Alaric WimerAlaric Wimer 

Why is my lookup field not automatically populating when I click my button?

I have a custom "Create Project" button for my Opportunity page that lets Users create a Project record directly from the Opportunity.

In the predefined fields, I have a look up field called PO Number that gets defined by the Opportunity's PO Number realted record. However, when I click on "Create Project", the field does not get populated. In the end after saving, a new Project gets created with no PO Number record.

How can I get this predefined field to populate? Why is not working? Here are some screenshots to show you what's happening:

Create Project button
PO Number look up field not populating
User-added image
User-added image

Andrew GAndrew G
Hi Alaric
Assuming PO_Number is the custom field on the Opportunity, try the formula purely as Opportunity.PO_Number__c

If we are talking about the Id of the related record, there is not need for the *__r nomenclature 

Regards
Andrew
Alaric WimerAlaric Wimer

Thanks for the reply, Andrew. The only problem is when I change it to Opportunity.PO_Number__c, the value becomes null even though the Opportunity's related list called "PO Numbers" populates with the correct PO Number. I have a workaround that fires a trigger everytime a PO Number is created, to update the Opportunity's PO_Number__c field but I really don't like that solution. I'd like to not use Apex here if possible, unless it's absolutely necessary. So basically, why is that custom lookup field PO_Number__c not populating on the Opportunity? Once that populates, then the Create Project button would have a value to map to the Project record. Here's some more images that might be helpful:


PO Number custom lookup field:

User-added image

Detail page of Opportunity record:
User-added image

Related page of Opportunity record:

User-added image

Andrew GAndrew G
Hi Alaric
I have quickly mimic'd your setup in a dev org.  The custom button works as expected.
User-added image

  Pardon the Namespace prefix, but the Opportunity.PO_Number__c reference works as expected.

As quick test shows that if I don't save the Opportunity after I insert the PO Number in the Opportunity, the New Project does come up with an empty PO Number.  Perhaps the issue lies there ??

Regards
Andrew
Bhawana Mehta SFDCBhawana Mehta SFDC
Hi Alaric.

This can be achieved in 2 steps:
a) PO Number lookup won't get auto-populated on opportunity out of the box.
To acahieve this , you will have to write a Process Builder on PO Number record, every time a PO record gets created, update it's opportunity with the PO Number record id.

b) Once you have the PO number data on Opportunity Detail page, it wil automatically flow to your Project record via the Quick Action button that you have created.