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
Scott Searle 10Scott Searle 10 

If Statement in a URL List Button to default Record Type based on the parent

I have built a URL button to create a new child record with some defaults, but I need an IF statement in the button to choose which record type. I tried this, but the If statement does not work. What is wrong with the If part of the statement?
/lightning/o/Project_Deliverable__c/new?{!IF(Proposal__c.RecordTypeId="0126t000000Ci5qAAC","recordTypeId=0126t000000Ci5CAAS","recordTypeId=0126t000000Ci57AAC")}&defaultFieldValues=,Proposal__c={!Proposal__c.Id},Name={!Proposal__c.Proposal_Number__c}%20-%20New%20Deliverable &backgroundContext=%2Flightning%2Fr%2FProposal__c%2F{!Proposal__c.Id}%2Fview
Best Answer chosen by Scott Searle 10
Scott Searle 10Scott Searle 10
In the end, this worked. I had to put recordTypeId= and then the If statement. 
/lightning/o/Project_Deliverable__c/new?recordTypeId={!IF(OR(Project__c.RecordTypeId=="0124x000000V7eS",Project__c.RecordTypeId=="0124x000000V7eR"),"0124x000000V7eIAAS","0124x000000V7eJAAS")}&defaultFieldValues=Project__c={!Project__c.Id},Name={!Project__c.Project_Number__c}%20-%20New%20Deliverable&backgroundContext=%2Flightning%2Fr%2FProject__c%2F{!Project__c.Id}%2Fview

 

All Answers

PriyaPriya (Salesforce Developers) 

Hi Scott,

Kindly refer this link for Conditional URL :-

https://help.salesforce.com/s/articleView?id=sf.customize_functions_i_z.htm&type=5

regards,

Priya Ranjan

Scott Searle 10Scott Searle 10
In the end, this worked. I had to put recordTypeId= and then the If statement. 
/lightning/o/Project_Deliverable__c/new?recordTypeId={!IF(OR(Project__c.RecordTypeId=="0124x000000V7eS",Project__c.RecordTypeId=="0124x000000V7eR"),"0124x000000V7eIAAS","0124x000000V7eJAAS")}&defaultFieldValues=Project__c={!Project__c.Id},Name={!Project__c.Project_Number__c}%20-%20New%20Deliverable&backgroundContext=%2Flightning%2Fr%2FProject__c%2F{!Project__c.Id}%2Fview

 
This was selected as the best answer