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
Fesal SuraitawalaFesal Suraitawala 

Custom "New" button that pre-selects the RecordType not working in Lighting

I have created a custom button that redirects to new record creation form with selected recordtype.
 
/a28/e?CF00N0v000004Ku31={TestName}&CF00N0v000004Ku31_lkid={TestId}&retURL=%2F{!ContactId}&RecordType=0120v000000SCPO&ent=01I0v000000MTi6

But this is not working properly in the lightning environment, it's open new form in a popup but after cancel does not redirect to return URL.

Please tell me if you have a better solution.
Ravi Dutt SharmaRavi Dutt Sharma
Hi Fesal,

You should consider using Quick actions instead of custom JS button. Please refer to this link: https://trailhead.salesforce.com/content/learn/modules/lex_javascript_button_migration/javascript_button_alternatives

Thanks,
Ravi
Fesal SuraitawalaFesal Suraitawala
Hi Ravi Dutt Sharma,

Thanks for quick reply.

I created a URL button, not a javascript.
This is the URL that I used in button:
/a28/e?CF00N0v000004Ku31={TestName}&CF00N0v000004Ku31_lkid={TestId}&retURL=%2F{!ContactId}&RecordType=0120v000000SCPO&ent=01I0v000000MTi6

I can also show it in lightning layout, but it's not working properly. It's open in a modal popup and when I cancel or save the form it does not redirect to return URL, just display a blank page.