web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Change variable after ...
Power Apps
Unanswered

Change variable after clicking a button - error

(0) ShareShare
ReportReport
Posted on by 264

Hi,

Can anybody tell me what is wrong with this specific code?

I would like to make an app, where the user must go through a few questions in one screen, and every time he clicks "successful", he should be moved to the next question (i made a variable ValTask which should change to the next question every time the user clicks the button).

I would like the variable to change and store the answer in a spreadsheet when the user clicks on the "successful" button, and my idea is for the variable to be changed every time he clicks the button, so after clicking question one it will change to 2, after question 2 it will change to 3, etc.

Could you advise me on what is wrong with my code? or just suggest some other solution if possible. Thank you for your time!

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,040 Most Valuable Professional on at

    Hi @pal95 ,

    Assuming that INSTALL is a Single Line of Text in your data source, try this

    If(
     ValTask = "Install" , 
     Patch(FacilitiesList, ValFacility, {’Install': "DONE"});
     Set(ValTask, "Raise on Lower Flyet Ball"),
     . . . . . .
    

    also if this is not the issue, try Install without the quotes''

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • WarrenBelz Profile Picture
    153,040 Most Valuable Professional on at

    Hi @pal95 ,

    Just checking if you got the result you were looking for on this thread. Happy to help further if not.

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • Verified answer
    v-yutliu-msft Profile Picture
    on at

    Hi @pal95 ,

    Do you want to change a field's value everytime you click the button by using variable?

    Please notice these points:
    1)Variable value will  restart every time you reopen this app. It will be blank when you start the app. How do you set this variable at the beginning?

    2)What does valfacility represent? how do you set? The second parameter of Patch function should be an existing record in the data source.

    I assume that valfacility is a record that you set as variable.

    If so, you should set like this:

    1)set the app's OnStart:

    Set(ValFacility,LookUp(FacilitiesList,....));//set a record as this variable, please fill in condition in the ... part
    Set(ValTask,
    Not(ValFacility.Install="Done"),"Install"
    ValFacility.Install="Done"&&Not(ValFacility.'Raise or Lower Flygt Ball'="Done"),"Raise or Lower Flygt Ball",
    ValFacility.'Raise or Lower Flygt Ball'="Done"&&Not(ValFacility.'Modify for failsafe 
     operation'="Done"),"Modify for failsafe 
     operation",,
    ValFacility.'Modify for failsafe 
     operation'="Done"&&Not(ValFacility.'Install IS Barriers'="Done"),""Install IS Barriers",
    ValFacility.'Install IS Barriers'="Done"&&Not(ValFacility.'Fix IS Barriers'="Done"),"Fix IS Barriers",
    ValFacility.'Fix IS Barriers'="Done","All is Done"
    )
    

    //you need to set this variable's value based on data base every time you open this app

    3)the button's OnSelect:

    If(ValTask="InStall",Patch(FacilitiesList,ValFacility,{Install:"Done"}),
    ValTask="...",Patch(FacilitiesList,ValFacility,{...:"Done"}),
    ValTask="....",Patch(FacilitiesList,ValFacility,{...:"Done"}),
    ValTask="....",Patch(FacilitiesList,ValFacility,{...:"Done"}),
    ValTask="....",Patch(FacilitiesList,ValFacility,{...:"Done"}),
    ValTask="All is Done",Notify("This task has been completed!",NotificationType.Warning)
    )

     //update data source based on variable value

     

     

     

    Best regards,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard