0

I have a custom object called Custom_Request__c with several record types. We have a custom lightning button on the opportunity product object to create a record of Custom_Request__c of recordtype "AMS Request". While creating a new record of Custom_Request__c object with "AMS Request" record type, we are autopopulating several fields from the Opportunity, Account and Opportunity Product and everything works fine.

Below is the code of the lightning button that is working.

/lightning/o/Custom_Request__c/new?recordTypeId=0127ZxxxxxxxxxQAK&defaultFieldValues=Name="Name will be calculated automatically",Account__c={!Opportunity.AccountId},Opportunity__c={!Opportunity.Id}

Now, I have created another custom lightning button to create the Custom_Request__c record of record type "AMS Dashboard". The button for creating this record will be on the Custom_Request__c record of "AMS Request" record type. I have created a custom lookup field called "Related Parent Request" on the Custom_Request__c object. The lightning button code is below.

/lightning/o/Custom_Request__c/new?recordTypeId=0127ZyyyyyyyyyQAK&defaultFieldValues=Name="Name will be calculated automatically",Account__c={!Custom_Request__c.Account__c},Opportunity__c={!Custom_Request__c.Opportunity__c},Related_Parent_Request__c={!Custom_Request__c.Id}

However, the above button code is NOT working. When I click on the button "AMS Dashboard" on the Custom Request record, the window popup opens, but except the Name field and Related_Parent_Request__c, nothing else is populating. The Account and Opportunity information for the new record should be taken from the Custom Request record of the "AMS Request" record type, but it is not happening. Moreover, the Account and Opportunity fields are NOT showing up on the new button. When I remove the Account__c from the lightning button code, it shows up in the "New" page layout. Once I add back the code Account__c={!Custom_Request__c.Account__c}, it disappears from the "New" page layout. FYI, I have tried with nooverride=true also and it doesn't help either.

Can someone help?

2
  • In your second URL, you're passing in Custom_Request__c fields, but the Custom_Request__c won't exist yet. Won't that by why they're not populating? i.e. Which Custom_Request__c would that URL be using?
    – Nick C
    Nov 21 at 12:06
  • The custom lightning button is meant to be clicked on an existing Custom_Request__c record of "AMS Request" record type. My understanding is that the lightning button code should be able to pull the values from the existing Custom_Request__c record. Nov 21 at 12:12

1 Answer 1

0

It was one of the weirdest thing I came to know about Salesforce. The lightning button worked when I changed the code as shown below.

/lightning/o/Custom_Request__c/new?recordTypeId=0127ZyyyyyyyyyQAK&defaultFieldValues=Name="Name will be calculated automatically",Account__c={!Custom_Request__c.AccountId__c},Opportunity__c={!Custom_Request__c.OpportunityId__c},Related_Parent_Request__c={!Custom_Request__c.Id}

The API name of Account on the Custom_Request__c is Account__c, but the lightning button needs AccountId__c. If I put Account__c or AccountId__c, Salesforce is not flagging any error message while syntax checking. But the auto populate functionality works when I use AccountId__c and OpportunityId__c in the lightning button.

Hope this helps someone.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .