Hi Guys,
I want to set a dropdown when I click a custom button "Submit". I did below in the button OnSelect and it was worked fine earlier..But I don't know why it is not working today..
Is there any update happened in PowerApps?.
Kindly advise if I am missing something..
SubmitForm(SharePointForm1);Patch('My List Name',First(Filter('My List Name',ID=SharePointForm1.LastSubmit.ID)),{"Request_x0020_Version": First(Filter(DataCardValue17.SelectedItems,Value = "Final"))})
Solved! Go to Solution.
My usual disclaimer is that there are always several ways to approach a solution. Here is one:
Introduce a local boolean-variable called varSubmitForApproval (you could name it anything, really) in the screen's OnVisible event. This instantiates the variable so that the app knows the datatype: true/false.
UpdateContext({varSubmitForApproval:false})
In your form's DataCard#.Update property, it should currently be equal myDropDown.Selected.Value. You can change it to something like this:
If(varSubmitForApproval=true, "Final", myDropDown.Selected.Value)
or if you want to be really nerdy, you can omit the "=true" part:
If(varSubmitForApproval, "Final", myDropDown.Selected.Value)
Since varSubmitForApproval is defined as "false" (in your Screen.OnVisible event), it will--by default--reference your dropdown list. Here's the catch. In your SubmitForApproval button, have this in the OnSelect event:
UpdateContext({varSubmitForApproval:true}); SubmitForm(SharePointForm1)
And then in your SharePointForm1.OnSuccess event, have the local variable reset itself with this syntax (and you may want to put the same syntax in the OnFailure event, just in case...):
UpdateContext({varSubmitForApproval:false})
The net result is that your form will always accept the dropDown value; however, when you click on the Submit-For-Approval button, it will switch the local variable to true. And then the form takes instruction in the DataCard#.Update property (If-Statement) to override the dropdown selection with "Final".
In this way, you avoid having to patch anything at all. Metaphorically, you give the parcel to the mailman before he leaves the building and avoid having to send your poor secretary to the post office to reconcile. I hope that helps, or at least gives you some avenue for further research.
SubmitForm(SharePointForm1); Patch('My List Name', First(Filter('My List Name',ID=SharePointForm1.LastSubmit.ID)),
{
"Request_x0020_Version": First(Filter(DataCardValue17.SelectedItems,Value = "Final"))
}
)
At first glance, it seems confusing what you are trying to do. Let me try to summarize what I initially see you doing here:
Here are some inconsistencies I see:
More context to your project/objective might be helpful in answering your question, but if I were a betting man, I would say your problem has to do with LastSubmit. If this is the case, then you have to relook at the design process of your form.
Thank you so much for your time...
I am using PowerApps SharePointForm1 opened using "Customize" from "My List Name"
1) I have a choice field in the SharePoint list called "Request Version" and it has two items "Draft" and "Final". I set the "Draft" as default in the choice field, because I want to set the field as "Draft" when user clicks on "Save" (OOTB) button
2) I have one custom button in the form called "Submit for Approval" and I want to set the dropdown value to "Final" when I hit this custom button from the add new item mode.
So tried to update the value to "Final" using Patch and LastSubmit. Please advise how can I do that..
Thanks in Advance.
My usual disclaimer is that there are always several ways to approach a solution. Here is one:
Introduce a local boolean-variable called varSubmitForApproval (you could name it anything, really) in the screen's OnVisible event. This instantiates the variable so that the app knows the datatype: true/false.
UpdateContext({varSubmitForApproval:false})
In your form's DataCard#.Update property, it should currently be equal myDropDown.Selected.Value. You can change it to something like this:
If(varSubmitForApproval=true, "Final", myDropDown.Selected.Value)
or if you want to be really nerdy, you can omit the "=true" part:
If(varSubmitForApproval, "Final", myDropDown.Selected.Value)
Since varSubmitForApproval is defined as "false" (in your Screen.OnVisible event), it will--by default--reference your dropdown list. Here's the catch. In your SubmitForApproval button, have this in the OnSelect event:
UpdateContext({varSubmitForApproval:true}); SubmitForm(SharePointForm1)
And then in your SharePointForm1.OnSuccess event, have the local variable reset itself with this syntax (and you may want to put the same syntax in the OnFailure event, just in case...):
UpdateContext({varSubmitForApproval:false})
The net result is that your form will always accept the dropDown value; however, when you click on the Submit-For-Approval button, it will switch the local variable to true. And then the form takes instruction in the DataCard#.Update property (If-Statement) to override the dropdown selection with "Final".
In this way, you avoid having to patch anything at all. Metaphorically, you give the parcel to the mailman before he leaves the building and avoid having to send your poor secretary to the post office to reconcile. I hope that helps, or at least gives you some avenue for further research.
Thank you so much!.
I did it in the DataCard#.Update property,
If(varSubmitForApproval, {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",Id:-1,Value:"Final"},
DataCardValue17.Selected)
It is worked as expected. Thanks.
Stay up tp date on the latest blogs and activities in the community News & Announcements.
Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
User | Count |
---|---|
203 | |
170 | |
62 | |
32 | |
31 |
User | Count |
---|---|
339 | |
269 | |
105 | |
71 | |
56 |