cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Aapok
Resolver II
Resolver II

Strange behaviour of Concurrent function and If statement

I'm experiencing some strange behaviour with the Concurrent function, and while I have found a way to circumvent the issue, I'm hoping someone could explain what is causing this issue.

 

I have a OnTimerEnd function, which first checks if a Sharepoint List item has been updated since the last time the timer finished. If the list has been updated, we refresh a gallery, and if not, we save user input to the list. My logic seems to work just fine, but while attempting to do this to three different items (in different lists) inside a concurrent function, I'm getting the following error "The function 'If' has some invalid arguments.'.

 

Below are some pseudocode examples:

 

 

 

If(
 !listItemUpdated, 
 //true
 Patch(someList, LookUp(someList, ID = someID), {col1: someValue, col2: someValue2,...},
 //false
 Refresh(someList)
)

 

 

 

Above code works as expected, indicating my logic and the Patch function work as they should.

 

 

Concurrent(
If(
 !listItemUpdated, 
 //true
 Patch(someList, LookUp(someList, ID = someID), {col1: someValue, col2: someValue2,...},
 //false
 Refresh(someList)
),
If(
 !list2ItemUpdated,
 Patch(someList2, LookUp(...

)

 

 

Copy pasting the working code inside the Concurrent function gives the error mentioned above.

 

 

Concurrent(
If(
 !listItemUpdated, 
 //true
 Patch(someList, LookUp(someList, ID = someID), {col1: someValue, col2: someValue2,...},
 //false
 Refresh(someList)
); Set(someVar, Blank()),
If(
 !list2ItemUpdated,
 Patch(someList2, LookUp(...

)

 

Now, if I add some other function inside the concurrent formula, the error disappears. I've tried using Set and Notify, and both seem to get rid of the error, so I'm assuming adding any functionality to the formula would get rid of the error.

 

I'm hoping someone could help me identify the cause of the error. If my pseudocode is too vague I can clarify it more in the comments.

 

Thanks in advance.

 

P.S. Hopefully the format of my post is good, it's my first time posting on these forums.

1 ACCEPTED SOLUTION

Accepted Solutions
timl
Super User
Super User

@Aapok

The likely cause of this problem is that because the call to 'if' is nested inside 'concurrent', Power Apps cannot parse the expression correctly.

It'll stem from the fact that it cannot evaluate a consistant return value from the call to 'if'.

Here, the true path of the 'if' statement returns a record (because that's what Patch returns), whereas the false path returns a boolean (the result of the Refresh operation).

 

If(
 !listItemUpdated, 
 //true
 Patch(someList, LookUp(someList, ID = someID), {col1: someValue, col2: someValue2,...},
 //false
 Refresh(someList)
)

 

If you were to adapt your 'if' syntax so that both paths return a boolean, that should hopefully resolve the error.

If(
 !listItemUpdated, 
 //true
 Patch(someList, LookUp(someList, ID = someID), {col1: someValue, col2: someValue2,...};
 true,
 //false
 Refresh(someList)
) 

 

View solution in original post

2 REPLIES 2
timl
Super User
Super User

@Aapok

The likely cause of this problem is that because the call to 'if' is nested inside 'concurrent', Power Apps cannot parse the expression correctly.

It'll stem from the fact that it cannot evaluate a consistant return value from the call to 'if'.

Here, the true path of the 'if' statement returns a record (because that's what Patch returns), whereas the false path returns a boolean (the result of the Refresh operation).

 

If(
 !listItemUpdated, 
 //true
 Patch(someList, LookUp(someList, ID = someID), {col1: someValue, col2: someValue2,...},
 //false
 Refresh(someList)
)

 

If you were to adapt your 'if' syntax so that both paths return a boolean, that should hopefully resolve the error.

If(
 !listItemUpdated, 
 //true
 Patch(someList, LookUp(someList, ID = someID), {col1: someValue, col2: someValue2,...};
 true,
 //false
 Refresh(someList)
) 

 

Thank you for taking the time to reply. I figured it must have been some sort of a parser issue.

While I still don't understand why adding some other functionality outside the If statement fixes the parser issue, I'm going to accept your post as the solution for clarifying the underlying parser issue. 

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.

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 (2,523)