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

Issues with Setting SharePoint field values with a button click and then getting that value on subsequent loads of the form - SharePoint Form

Not sure i have titled this right.

 

I have a sharepoint form for a list that i am customizing.   As such i have a "SharePointForm" Group along with data cards for each of the fields.   One field i have is "Status"   On load of the form i am wanting it to say "new"   Which i can do successfully.   However when a user selects "Save as draft"  If the form is in Draft or New status already,  i want it to set the "Status" field to "Draft"    if the user clicks "Submit"  and the form is in New/Draft status,  i want the status to move to "Submitted".   There are other points throughout the processs where users will need to open and update the form.   and other statuses.    So,  what i have is the following:

 

on the "Save as Draft" field,  i am using the following:

 

If(DataCardValue5.Text = "", UpdateContext({Var_Status: "Draft"}), UpdateContext({Var_Status: DataCardValue5.Text}));
SubmitForm(SharePointForm1)

  

On the DataCard i have the default value set to "Var_Status"   and this successfully sets the value and saves the form.  The issue i am having, is that every time the form Loads,   Status is blank instead of pulling through the current status value.   This makes sense to me as the "Var_Status" variable would be blank at this point.   I have attempted to set this variable on form load (OnEdit, OnView events) however because at that point SharePointForm1.Selected is blank,  i am unable to determine which "Status" value to get.

 

Any suggestions on how i can accomplish this would be greatly appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
MarkTurner
Regular Visitor

I managed to solve it.   

 

For those who may come here in future looking for a solution it is below.

 

Instead of using a global variable,  i used only code on the button.

 

If(IsBlank(DataCardValue5.Text) Or IsEmpty(DataCardValue5.Text), Patch(MyList, SharePointIntegration.Selected, {FormStatus: "Draft"}), Patch(MyList, SharePointIntegration.Selected, {FormStatus: DataCardValue5.Text}));
SubmitForm(SharePointForm1)

I had Tried patch Previously,  however instead of using "SharePointIntegration.Selected"   i tried to use "ThisItem"   once i started using SharePointIntegration.Selected it worked without issue.   This allowed me to set the value as expected without using any variables/other "funky" ways of doing things that i had found in other posts.

View solution in original post

1 REPLY 1
MarkTurner
Regular Visitor

I managed to solve it.   

 

For those who may come here in future looking for a solution it is below.

 

Instead of using a global variable,  i used only code on the button.

 

If(IsBlank(DataCardValue5.Text) Or IsEmpty(DataCardValue5.Text), Patch(MyList, SharePointIntegration.Selected, {FormStatus: "Draft"}), Patch(MyList, SharePointIntegration.Selected, {FormStatus: DataCardValue5.Text}));
SubmitForm(SharePointForm1)

I had Tried patch Previously,  however instead of using "SharePointIntegration.Selected"   i tried to use "ThisItem"   once i started using SharePointIntegration.Selected it worked without issue.   This allowed me to set the value as expected without using any variables/other "funky" ways of doing things that i had found in other posts.

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Solution Authors
Top Kudoed Authors
Users online (2,466)