Skip to main content
I'm URL hacking a list button and finding that it's not behaving properly when handling text fields that contain commas even though I'm using URLENCODE. I'm running into the issue when setting a default value for the Name field of Objective__c based on the Name field of Plan_of_Care__c.

 

This works:

{!URLFOR(

"/lightning/o/Objective__c/new?defaultFieldValues="

+ "Plan_of_Care__c=" & CASESAFEID ( Plan_of_Care__c.Id )

+ ",Name=" + URLENCODE(SUBSTITUTE(URLENCODE( LEFT ( "Objective for " + Plan_of_Care__c.Name , 80 ) ), ',', '%2c')) 

+ "&backgroundContext=%2Flightning%2Fr%2FPlan_of_Care__c%2F" + CASESAFEID ( Plan_of_Care__c.Id ) + "%2Fview"

)}

This doesn't work:

{!URLFOR(

"/lightning/o/Objective__c/new?defaultFieldValues="

+ "Plan_of_Care__c=" & CASESAFEID ( Plan_of_Care__c.Id )

+ ",Name=" + URLENCODE( LEFT ( "Objective for " + Plan_of_Care__c.Name , 80 ) )

+ "&backgroundContext=%2Flightning%2Fr%2FPlan_of_Care__c%2F" + CASESAFEID ( Plan_of_Care__c.Id ) + "%2Fview"

)}

I would think that URLENCODE would handle the commas without me having to manually replace them---what am I missing?

 

 
4 respuestas
  1. 23 abr 2021, 15:14
    I ended up having to go forward with the option in my original post that uses the SUBSTITUTE function
0/9000