I have a requirement where I need to autopopulate a few fields when a user clicks the button and creates a record from a lightning page. The button will be on service contract and when a user clicks the button to create a case for a particular record type the fields like opportunity, case subject line, and some other fields get autopopulate and user can enter other fields on the layout and create case. ideally it should work both in lightning and classic but if we can only do lightning thats fine too. Will a Flow with lighning action work? Can I create before save flow for this? or Should i create the url hacking but i am not sure if it would go multilevels as i have fields that are from opportunity and other objects. Is there any other solution that can work which requires less code.
2 Answers
Sounds like an object specific quick action.
-
2While this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. Commented Sep 29, 2022 at 23:39
-
-
You can use custom buttons. Since you wanted this button on the "ServiceContract" object, create the button on the object. Select detail page button because you want a Case record to open up with prepopulated values from ServiceContract. Use following url pattern to create Case (Case record opens up in edit mode with fields specified in the URL pre-populated)
/lightning/o/Case/new?defaultFieldValues=Priority=High,Subject=Hello WOrld,AccountId={!ServiceContract.AccountId}
Go to the page layout of Service Contract and add this button to "Salesforce Mobile and Lightning Experience"
You can go Scree Flow route if you need to populate Case with details from i=unrelated records or if some kind of data processing and manipulation is required