cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
newer_onn
Regular Visitor

Updating Parent Relation when creating a new Child record

There are two entities which are Client Notes and Client Engagement on CDS and there N to 1 relationship between them. We’ve created a Canvas app which lists the Client Notes linked to Client Engagement on Dynamics. Also you can create a new Note record linked to selected Client Engagement record on Dynamics.

 

We made that relation and calling the Page created by Canvas App with the code below. The code is written on onload of the Client Engagement form.

 

newer_onn_0-1668531722469.png

 

 

We feed the Client Engagement ID to Canvas App with recordID parameter. This parameter is set to Var1 onStart of App.

            Set(Var1,Param("recordId"));

Whenever a new Note record is created, it is linked to parent Client Engagement record with the DataCard on Canvas app. This Datacard combobox is on the new Note form.

Default property of Combobox Datacard is:

If(IsBlank(ThisItem.'Client Engagement'),

LookUp('Client Engagement',Advice=GUID(Var1)),

ThisItem.'Client Engagement')

We’re having performance issue on Canvas app , it happens on different areas, it sometime happens when saving the data , sometimes deleting the data, sometimes going back to main screen, etc..

I’ve monitored the app and seen that DataCard which is for parent Client Engagement fetching all data first and this is really big data in the system. When I get rid of Datacard combobox from Form, performance is back to normal.

I want to find a way to link the new Note record with Parent Client Engagement record without using Datacard.

I used PATCH function onSelect event of Save Button on New Record create form like below:

 

If(!IsBlank(Filter('Client Notes', 'Client Engagement'.Advice=GUID(Var1))),

SubmitForm(Form2),(

Patch('Client Notes',

      Defaults('Client Notes'),

      {   Name: DataCardValue5.Value,

          'Note Type': DataCardValue2.Selected.Value,

          'Note Text': DataCardValue3.Value,

          'Client Engagement':LookUp('Client Engagement',Advice=GUID(Var1))

      }

)));

 

If I switch from Gallery view of Notes to New Note Create Form, I’m not able to get Parent record’s ID while using patch and updating record. Hence newly created Notes are not linked to any parent Client Engagement. How can I get parent record ID when I am creating a new child record?

Or Could you advise something to improve performance even if I use Datacard for parent record relation? I read articles about how to improve performance of canvas app and applied some changes, made good progress but still it is not acceptable level.

Thanks in advance for all your response,

 

1 REPLY 1
newer_onn
Regular Visitor

For your interest, I've sorted out the issue by adding the function below into on select of Add new Note button.

I'm sending parent ID to new Note record.

Navigate(Form2, None,{CEID:Var1});

 

And saving the new Note record with the code below:

 

If((!IsBlank(DataCardValue2.Selected.Value) && !IsBlank(DataCardValue3.Value)),
If(newRecord,
Patch('Client Notes',
Defaults('Client Notes'),
{ Name: DataCardValue5.Value,
'Note Type': DataCardValue2.Selected.Value,
'Note Text': DataCardValue3.Value,
'Client Engagement':LookUp(Choices([@'Client Notes'].ow_ClientEngagement),Advice=GUID(CEID))
}
);UpdateContext({ShowMessage: false}),
Patch('Client Notes',
LookUp('Client Notes',Note=noteSelected.Note && Name = noteSelected.Name),
{ 'Note Type': DataCardValue2.Selected.Value,
'Note Text': DataCardValue3.Value
}
);
UpdateContext({ShowMessage: false})),UpdateContext({ShowMessage: true}));
If (!ShowMessage,
Form2.Visible=false;
Set(newRecord, false);
Navigate(ClientNotes);
ResetForm(Form2));

 

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

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

Community Call Conversations

Introducing the Community Calls Conversations

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

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,366)