Hello friends,
I have an issue. I have a list on the SharePoint Site that looks:
Then I have tried to customize Edit Form on PowerApps that uses a global variable for the SharePointIntegration.Selected record.
I have added the following code OnEdit event of SharePointIntegration component:
And OnCancel event:
On the screen, I have a form that uses the SharePointIntegration.Selected record as Item
And a label that uses the variable
(All the following photos contain a part of the SharePoint list on the left side and custom PowerApps in Edit mode on the right)
And then when I open the form on the SharePoint first time everything works well
Then I close the form and try to open it for another record and it works for but not for my variable.
If I open third time another record the form works but a variable shows me the second record.
So, do you happen to know how to set a global variable properly?
(I understand that I may use the SharePointIntegration.Selected record for the label as well but my purpose is to use this record for setting other variables)
Solved! Go to Solution.
Hi @Smile1 ,
Yes, I can also reproduce your issue, and can't find out the reason of this issue for the time being.
However, here is another workaround, change to use LookUp function to retrieve back the record upon the 'SharePointIntegration.SelectedListItemID', rather than 'SharePointIntegration.Selected'.
Please try to modify the code as follows.
Set(
SelectedWorkflow,
If(
IsBlank(SharePointIntegration.Selected) || IsEmpty(SharePointIntegration.Selected),
First([@'SP list']),
LookUp('SP list',ID= SharePointIntegration.SelectedListItemID)
)
);
Hope this helps.
Sik
Hi @Smile1 ,
Yes, I can also reproduce your issue, and can't find out the reason of this issue for the time being.
However, here is another workaround, change to use LookUp function to retrieve back the record upon the 'SharePointIntegration.SelectedListItemID', rather than 'SharePointIntegration.Selected'.
Please try to modify the code as follows.
Set(
SelectedWorkflow,
If(
IsBlank(SharePointIntegration.Selected) || IsEmpty(SharePointIntegration.Selected),
First([@'SP list']),
LookUp('SP list',ID= SharePointIntegration.SelectedListItemID)
)
);
Hope this helps.
Sik
Thanks, it works.
It works perfectly except for the first-time run (I guess it is related to App initialization. tried the same code-snippet in the App OnStart, but unfortunately didn't make any difference. still brings the
First([@'SP list'])
as a result and not the SharePoint selected item.
Any suggestions please, am really tired of this bug, been days now, and my form is quite complex enough
Curious - did you ever find a solution to fix the first run?
I am having a similar problem. I have tried to set a global variable (Boolean: E.G. varNewForm = true) to capture when the form is new vs. when it is being edited. PowerApps defaults to an "Edit" form mode, regardless of the form being started as "New", so this is my attempt at a workaround.
When I open a New form, the variable is set to "true" correctly. However, when I then open an item to "Edit", the variable does not get set the first time. Then when I open the item again, the variable does get set to "false". I do not understand why my code will run the second time, but not the first. Very frustrating.
User | Count |
---|---|
251 | |
102 | |
94 | |
47 | |
37 |