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

Issue with concurrent function

Hi

 

I am having an issue with the concurrent() function. I have a SQL table (Using a SQL server connection) that has three fields which has to be updated when certain conditions are met. I use the UpdateIf function to update these. However when I use the UpdateIf in a Concurrent function to make all three UpdateIf's to run simultaneously I get an error. What am I doing wrong?

 

The function is:

Concurrent(
UpdateIf(
'[dbo].[MRP]';
And(
ParentGUID = Gallery1.Selected.ParentGUID;
IsBlank(Gallery1.Selected.ParentGUID) = false
// IsBlank(Gallery1.Selected.ChildGUID) = false
);
{Mål: DataCardValue6_1.Text}
);
UpdateIf(
'[dbo].[MRP]';
And(
ParentGUID = Gallery1.Selected.ParentGUID;
IsBlank(Gallery1.Selected.ParentGUID) = false
// IsBlank(Gallery1.Selected.ChildGUID) = false
);
{Afsnit: DataCardValue8_1.Selected.Text}
);
UpdateIf(
'[dbo].[MRP]';
And(
ParentGUID = Gallery1.Selected.ParentGUID;
IsBlank(Gallery1.Selected.ParentGUID) = false
// IsBlank(Gallery1.Selected.ChildGUID) = false
);
{Målnr: DataCardValue40.Selected.Value}
)
)

1 ACCEPTED SOLUTION

Accepted Solutions
Super User III
Super User III

@HardeepSingh 

Please consider changing your Formula to the following:

UpdateIf(
   '[dbo].[MRP]';
   ParentGUID = Gallery1.Selected.ParentGUID; 
   {
    Mål: DataCardValue6_1.Text;
    Afsnit: DataCardValue8_1.Selected.Text;
    Målnr: DataCardValue40.Selected.Value
   }
)

What you are doing you can do with one UpdateIf.  There is no need to perform three actions on the same record to update 3 columns.

Also, you can remove the And operation on the Gallery1.Selected.ParentGUID.  If it is empty then this formula will simply do nothing.  If it has a value, then it will perform as expected.

 

I hope this is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

5 REPLIES 5
Super User II
Super User II

Hi @HardeepSingh 

I think that patching the same datasource using concurrent probably "confuses" PowerApps.  From the documentation on Concurrent():

You can't predict the order in which formulas within the Concurrent function start and end evaluation. Formulas within the Concurrent function shouldn't contain dependencies on other formulas within the same Concurrent function, and Power Apps shows an error if you try.

 

Hi Drrickryp

 

Thank you for a quick answer! Would it be possible to update the three fields using one UpdateIf function or anything similar, as essentially the three functions has the same If conditions? 

Dual Super User II
Dual Super User II

@HardeepSingh 

 

I would recommend you to remove the concurrent function as this will try updating same items at one for different values based on the expression you shared. You can update your expressions to:
UpdateIf(
'[dbo].[MRP]';
And(
ParentGUID = Gallery1.Selected.ParentGUID;
IsBlank(Gallery1.Selected.ParentGUID) = false
// IsBlank(Gallery1.Selected.ChildGUID) = false
);
{Mål: DataCardValue6_1.Text}
);;
UpdateIf(
'[dbo].[MRP]';
And(
ParentGUID = Gallery1.Selected.ParentGUID;
IsBlank(Gallery1.Selected.ParentGUID) = false
// IsBlank(Gallery1.Selected.ChildGUID) = false
);
{Afsnit: DataCardValue8_1.Selected.Text}
);;
UpdateIf(
'[dbo].[MRP]';
And(
ParentGUID = Gallery1.Selected.ParentGUID;
IsBlank(Gallery1.Selected.ParentGUID) = false
// IsBlank(Gallery1.Selected.ChildGUID) = false
);
{Målnr: DataCardValue40.Selected.Value}
)

 


Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

@HardeepSingh 

Take a look at @mdevaney 's blog post.  He has some ideas for how to speed up the process.  https://matthewdevaney.com/patch-multiple-records-in-power-apps-10x-faster/ 

 

 

 

 

 

Super User III
Super User III

@HardeepSingh 

Please consider changing your Formula to the following:

UpdateIf(
   '[dbo].[MRP]';
   ParentGUID = Gallery1.Selected.ParentGUID; 
   {
    Mål: DataCardValue6_1.Text;
    Afsnit: DataCardValue8_1.Selected.Text;
    Målnr: DataCardValue40.Selected.Value
   }
)

What you are doing you can do with one UpdateIf.  There is no need to perform three actions on the same record to update 3 columns.

Also, you can remove the And operation on the Gallery1.Selected.ParentGUID.  If it is empty then this formula will simply do nothing.  If it has a value, then it will perform as expected.

 

I hope this is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (63,698)