0

On Custom button i am passing the url and In below code snippet Notes__c field is long text area field. when i click on custom button values are populating but in notes field if user mention comma then from comma text is not populating.

For example if notes have text - the user, parent account values are active. In above line only the User text is showing on button click.

   {!URLFOR('/lightning/o/Request__c/new? 
      &recordTypeId=0220W000001PEqPQz0&defaultFieldValues=Request_Name__c)='+ 
    (RetailCustomer__c.Request_Name__c)+Notes__c='+URLENCODE(RetailCustomer__c.Notes__c)}

3 Answers 3

2

@cloudZigZag, you should use something like URLENCODE(SUBSTITUTE(TEXT, ',', '%2c'))

1
  • 1
    please add an explanation as to why your solution works vs simply code dumping an answer stating "this should work" or 'try this".
    – glls
    Mar 30, 2021 at 19:22
1
  1. The documentation for the base URL is inconsistent; in this case it recommends using $Action.Request__c.New or similar rather than hard-coding the host-relative URL form, but in this case it suggests a hard-coded host-relative URL.
  2. Since you have taken the second approach, I don't believe you require the use of URLFOR.
  3. You haven't used the correct syntax for the URL query parameters.
  4. This isn't considered URL hacking any more since this is directly supported functionality rather than a workaround.

Try something like:

/lightning/o/Request__c/new?recordTypeId=0220W000001PEqPQz0
    &defaultFieldValues=Request_Name__c={!URLENCODE(RetailCustomer__c.Request_Name__c)},      
        Notes__c={!URLENCODE(RetailCustomer__c.Notes__c)}

You can see an example of this sort of usage in the documentation.

2
  • yes, but the problem is in that we have lookup fields also, if lookup field don't have a the value this thing will show the error Oct 5, 2020 at 10:28
  • @cloudZigZag can you please edit your question to explain your additional concerns in a bit more detail?
    – Phil W
    Oct 5, 2020 at 11:32
0

add nooverride=true in the url then try:

/lightning/o/Request__c/new?nooverride=true&recordTypeId=0220W000001PEqPQz0 &defaultFieldValues=Request_Name__c={!URLENCODE(RetailCustomer__c.Request_Name__c)},
Notes__c={!URLENCODE(RetailCustomer__c.Notes__c)}

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.