Re: Patch function does not work at the beginning when the app is loading
@StevenZhang
I have re-oraganized your code making it easier to read. Also, I removed the PATCH functions that were commented out.
UpdateContext({showbackarrow_in_updatestatus: false});
UpdateContext({myprogressvalue: Value(DataCardValue86.Text)});
UpdateContext({myKRstatus: DataCardValue1.Selected.Value});
Patch(
'Individual OKR',
First(Filter('Individual OKR', ID = GalleryKR.Selected.ID)),
{ProgressValue:myprogressvalue}
);
Patch(
'Individual OKR',
First(Filter('Individual OKR', ID = GalleryKR.Selected.ID)),
{Status_OKR:myKRstatus}
);
Patch(
'Individual Objective',
First(Filter('Individual Objective',ID = MyselectedObj.ID)),
{Completion_MyObj:CompletionofMyObjective.Text}
);
SubmitForm(AddStatusofMyKRForm)
I would like you to replace your code with this instead. I've made a few improvements. FIRST + FILTER is very slow. Instead you can simply use the LOOKUP function. I've also put a CONCURRENT function in there to run all the PATCH functions simultaneously.
// store values in variables
UpdateContext({showbackarrow_in_updatestatus: false});
UpdateContext({myprogressvalue: Value(DataCardValue86.Text)});
UpdateContext({myKRstatus: DataCardValue1.Selected.Value});
// patch datasource
Concurrent(
Patch(
'Individual OKR',
LookUp('Individual OKR', ID = GalleryKR.Selected.ID),
{ProgressValue:myprogressvalue, Status_OKR:myKRstatus}
),
Patch(
'Individual Objective',
LookUp('Individual Objective',ID = MyselectedObj.ID),
{Completion_MyObj: CompletionofMyObjective.Text}
)
)
Lets test the PATCH functions first and see if they work. Do not include the SUBMITFORM function for now. We want to isolate what we are testing.
---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."