cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper III
Helper III

Create a variable in PowerApps to custom a SharePoint List?

Hello,

 

 There is a text field named "Flag", default value ="Y", I want it changes to "N" when cilcking on the "Save" button, the formulas as below:

OnSelect of the "Save" button:

 

UpdateContext({varFlag:OSART.Flag,value:"N"});SubmitForm(SharePointForm1)

 

onStart of APP : set(varFlag, OSART.Flag)  (not sure it is the right place, should be OSART.Flag (listname.fieldName)

 

it is not working. 😞 

 

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
Super User II
Super User II

@Linda777 

Don’t use choice fields in SharePoint. Change it to single line of text and set the options by hard coding them in the PowerApps controls.

View solution in original post

6 REPLIES 6
Super User II
Super User II

Hi @Linda777 

Global variables cannot be used as a context variable. If you use Set() in the OnStart property of the app, you will need to be consistent throughout the app and use Set() to change the state of the variable, not UpdateContext().

Hi Drrickryp,

Yes, Now I learn the local and gable variable.  it works

1.  default of the Flag field :  If(SharePointForm1.DisplayMode=FormMode.New,Parent.Default,varFlag)
2. Onselect of the button:
UpdateContext({varFlag:"N"});SubmitForm(SharePointForm1)

Thanks,

One small change,  I would put the UpdateContext({varFlag:"N"}) in the OnSuccess property of the form. I don't think that you want it to change unless the form successfully submits the record.  IMHO, rarely put anything but SubmitForm() in the button that actually submits the form as you don't want to execute additional commands unless the form submits successfully.

Hello Drrickryp,

As you can see, I am new in PowerApps, I am trying step by step, I want the field to be changed is choice type, now it is working if I put the formula as below in the"onSelect" of the button. 

 

If(DataCardValue15.Selected.Value="NEW",UpdateContext({varStatus:LookUp(Choices(OSART.Status),Value="ASSIGNED") }),false);

then I put it in the "OnSuccess" property of the form as you suggest,  it is not working, I am not sure if the datacardValue is not correct in here or anything wrong as I don't know what should change if move from a property  of the button to a property of the form. a lots need to learn. 
Thank you very much for your tips. 🙂

Super User II
Super User II

@Linda777 

Don’t use choice fields in SharePoint. Change it to single line of text and set the options by hard coding them in the PowerApps controls.

View solution in original post

Thanks Drrickryp. I will do. 🙂

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (17,621)