cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
varshinims08
Helper III
Helper III

Linking parent and child records automatically

Hi all, 

I want to build a flow to link parent and child records of same entity. Here is the scenario, I have entity A. When a new record is created in entity A it will check for duplicate record using "List rows" connector, if record already exist then i want to add newly created record(child) to already existing record(parent). How can I do this?

 

I tried to use "relate rows" connector, but i am getting error as Action 'Relate_rows' failed.

 

Thanks.... 

11 REPLIES 11
Mira_Ghaly
Dual Super User
Dual Super User

@varshinims08 

What is the relation between Parent and child is it 1:N?

 

If this post helps you with your problem, please mark your as Accepted solution.If you like my response, please give it a Thumbs Up.

Blog: here
varshinims08
Helper III
Helper III

@Mira_Ghaly

 

Yes.. It is 1:N relationship. When I am creating records in entity it is linking correctly, But when testing in flow it is throwing error as

9f3b6e72-e4b1-4002-8f73-84dbb42150c2.png

Sometimes its working fine, sometimes showing error. I dont know what is wrong.

Thank you... 

Mira_Ghaly
Dual Super User
Dual Super User

@varshinims08

Can you please add a screenshot to the step where u create the child record and how you are setting the lookup? 

If this post helps you with your problem, please mark your as Accepted solution.If you like my response, please give it a Thumbs Up.

Blog: here
varshinims08
Helper III
Helper III

@Mira_Ghaly

 

Here i am creating a child record,

98244e0e-b168-4618-9c67-f684a3a6119a.png

 and this is my flow

67ed9716-553a-40a5-9f9e-4062d0256247.png

a48c6f22-b26c-4722-a4f3-6034d7bed670.png

f4e97c7b-3df3-4a3b-8724-fc614c7659a8.png

Thank you

Mira_Ghaly
Dual Super User
Dual Super User

@varshinims08 

To set a lookup ok the child entity you do not need to use relate rows , Relate rows for N:N Relationships

 

so while creating your child set the lookup to the parent as below:

/parentshemanameinplural/ParentGUID

 

To get your parent Schema Name, go to make.powerapps.com and go to tables -> Select your Table and Click Settings

Mira_Ghaly_0-1613109730111.png

Note: SchemName while passing lookup should be in Plural+ Lower Case

 

 

If this post helps you with your problem, please mark your as Accepted solution.If you like my response, please give it a Thumbs Up.

Blog: here
varshinims08
Helper III
Helper III

@Mira_Ghaly  Thank you

 

I was able do it. But I want all the child records to have single parent.

But in my case i set Top Count as 2, so 1st child will have 1st existing record as parent and all other childs will have child 1 as parent...

If i set Top Count as 1, then no parent record will be atteched to the child..

 

How to achieve this? 

Mira_Ghaly
Dual Super User
Dual Super User

@varshinims08

Can you share screenshots of your flow so that I can understand the issue? 

If this post helps you with your problem, please mark your as Accepted solution.If you like my response, please give it a Thumbs Up.

Blog: here
varshinims08
Helper III
Helper III

@Mira_Ghaly

 

Here is my flow 

640ec560-a4b3-4a4e-b6a9-c93be284a50f.png

5930a521-87b3-4678-98c1-97be107a9b3f.png

85c85986-5000-4cb8-8ad9-38fef68f231a.png

cb729743-341b-4afa-a5e4-3a71ada5e1d2.png

The problem is if i choose Top count as 1 in List rows, the results of conditions in 'Apply to each' will be 'true'.....Even if all the values are correct  to get the false result.

 

And I am trying to update the record from the 'when a row is created' trigger

I have created a look up field called parent claim with N:1 relationship and trying to update that field with record from List row action.

BUT i am getting NotFound error in Update action.

 

If I use the delete action with Same GUID, it is working. But only Update action is not working.

 

And if  I try to delete the record which i got from list rows, it is deleting the record successfully, 

But if i try to delete the record from 'when a row is created' trigger, it is deleting but in showing error in Apply to each condition as ActionFailed. No dependent action succeeded. 

 

Sorry for posting more than one thread here.

I am new to Dynamics and I am not getting what is wrong with my flow. 

 

Thank you... 

Mira_Ghaly
Dual Super User
Dual Super User

@varshinims08 

Here you need to pass only the Id , which is the id from List Rows so Just pass GUID because this is the ID of the record and not a lookup

Mira_Ghaly_0-1613340011346.png

 

If this post helps you with your problem, please mark your as Accepted solution.If you like my response, please give it a Thumbs Up.

Blog: here
Mira_Ghaly
Dual Super User
Dual Super User

@varshinims08 

 

Have you managed to fix the above issue?

 

If this post helps you with your problem, please mark your as Accepted solution.If you like my response, please give it a Thumbs Up.

Blog: here
varshinims08
Helper III
Helper III

Hi @Mira_Ghaly

No, the issue is still there..

And i will get error with all the connectors. 

 

Now I created a new flow using CDS connectors and it is working fine. Previously I was using CDS(Current environment) connectors.

 

This below expression is also not working for me with CDS (Current environment) connectors.

 

length(outputs('List_rows')?['body/value'])  is equal to 0.

 

I will again try to build a new flow with (Current environment) connectors and will update here if I can able solve the issue.

 

 

Thank you... 

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (6,161)