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.
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.
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)
)
WarrenBelz
146,651
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,999
Most Valuable Professional