Use case - Navigate to custom object record automatically from screen flow and auto close the flow screen.
Now a days flow are so advanced we need to leverage flow as much as possible to avoid apex programming.
Requirement - Create customobject__c record from Lead coping all the values from anotherCustom__c.Both objects are child to Leads.
There are many ways to achieve to do so. Below is approach I followed to achieve it.
1. Created Before trigger flow to map all the fields of customobject__c from anotherCustom__c object.
2. Created action in Lead. That action can call lighting component, Visualforce page, and screen flow.Since I'm determined to go via less code, so I leveraged screen flow option. Screen flow contains 2 elements. A. Create Record and B. screen where one aura component loaded.
3. Create Record - This will insert customobject__c record, just mapped only one field Lead Id. Because based on Lead Id, the other flow will make query to pull info from another custom object and then map to custom_object
When Create Record action will be executed then automatically before triggered flow will also be executed so all fields will be mapped. No issue in the data.
Now the next task how to navigate to record page, also need to close the flow screen.
4. Create a aura component which will accept one parameter from flow that is Customobject id then navigate to record page. then close the flow screen.
Here is the component - Flow Redirect
This can be used to to close any flow and to redirect to any record page. This is a generic component.
Component code -
No comments:
Post a Comment