In previous post I examine the usability of the flow with all its new features by building flow that allow to merge 2 accounts. The main conclusion was that the flow is very powerful tool and can be used to build complex processes. It does missing flexibility when working with sObject or when want to apply enhance styling to your application.
In this post I decided to try and build similar process with web component- that is component can be embedded on any record page and allow to merge other record into the current record.
The full code can be found in this repository
How it will work? The component - mergeRecordsComp - can be placed on any record page. It will show search input where the user can type and search other record. For this purpose I'm using additional custom component - customLookupComp - as Salesforce still doesn't have build-in input for that.
After the input record was selected popup is opened that shows in table the values from the main record (record were we started the process) and the values from the second record (record that was selected in the search) in the second column.
By default all the values for the merge will be taken from the main record, but user can click on specific fields from the second record that he want to set in the merged record.
At the bottom, user can choose if he want to merge also the child records.
*For this demo I just added 1 checkbox that used as merge all child data all none, but can quite easily add higher flexibility, like getting dynamically all the sObject related list using ChildRelationship class and allowing the user to choose which he want merge. in apex you can find object related list with the following code:
Schema.DescribeSObjectResult dsr = Schema.getGlobalDescribe().get('Account').getDescribe(); for(Schema.ChildRelationship childRelation : dsr.getChildRelationships()){ System.debug('getChildSObject:: ' + childRelation.getChildSObject()); System.debug('getRelationshipName:: ' + childRelation.getRelationshipName()); System.debug('getField:: ' + childRelation.getField()); }
No comments:
Post a Comment