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
sksfdc221sksfdc221 

How to create new parent record when field value doesn't matches the parent record

I have an custom object called Account_Velocity__c and it has a child object called Partner_Policies__c
Now, there is an automation in place which inserts Account_Velocity__c and its related child Partner_Policies__c. 

I have a requirement where, if the Partner_district__c field of Partner_Policies__c doesn't match with its parent's Account_District__c field, a new parent record should be created and this related Partner_Polcies__c record should go as a child record for that parent.

As of now, for a single Account_Velocity__c record, there are multiple Partner_Policies__c records which are inserting as a child irrespecive of Partner_district__c and Account_District__c field values. 

simple terms for understanding: 
Parent - Account_Velocity__c, field - Account_District__c
Child - Partner_Policies__c, field - Partner_District__c

I'm having very hard time finding appropriate logic for this requirement. Could anyone please help me out with this.  
ShirishaShirisha (Salesforce Developers) 
Hi,

Greetings!

You can create the flow to check,if you have any duplicate records using flow by querying and insert the record,if you do not find any.

Please check the below documentation for the sample duplicate logic.

https://www.auraforce.ca/2015/02/avoid-duplicate-records-using-visualflow.html

Kindly let me know if it helps you and close your query by marking it as best answer so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
sksfdc221sksfdc221

Hi Shirisha,

Could you please let me know if this flow clone/copies the values from existing parent record if the district field of parent and child doesn't matches.