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 / Using variables as Def...
Power Apps
Unanswered

Using variables as Default Value, without neglecting Parent.Default

(0) ShareShare
ReportReport
Posted on by

Basically, i am writing a powerapps form (via Powerapps Web) connected to a sharepoint list. I have a status field (Text field) that normally has Parent.Default set as Default value. However, i also have a button in that app. When i click that button i want to set the status to 1. Doing that i would have to set a variable as the default value of the status and set it to 1 in the buttons onSelect. 

 

However, when i set the default value of the status to the variable, it will no longer show me what is the actual value in the sharepoint list and (i assume) also not save it there, since the default value is no longer Parent.Default.

 

How do i fix this issue? 

Categories:
I have the same question (0)
  • Gerard Simpson Profile Picture
    2,987 Moderator on at

    Hi @Anonymous - I'm assuming you only want to add this variable value to the field if the field is blank or is there a chanced you would add the variable to overwrite an existing value? For the former, scenario one way to work around this is to add logic, which checks if the value for that field in the datasource is blank. If it's not blank show Parent.Default - if it is blank, show the variable.

     

    You could try the following in the default property:

     

    Coalesce(Parent.Default, YourvariableName)

     

    For the other scenario, where you want the option to potentially add the variable value at anytime regardless of what existing value is in that field, you could just reverse the logic and check if the variable is blank. If it isn't, show the variable, if it is, just default to Parent.Default:

     

    Coalesce(YourvariableName, Parent.Default)

     

    You will need to ensure you set your variable back to blank at the right moment in your logic, potentially onsucess of your form submission.

     

    Hope this helps

     

  • Community Power Platform Member Profile Picture
    on at

    So the button originally has 0 set. I set that as the default value in the Sharepoint List. When i click the button i want to change that 0 into a 1. The rest of the status values will be controlled by a flow.

     

    How would i import that logic into powerapps? Thanks in advance!

  • Gerard Simpson Profile Picture
    2,987 Moderator on at

    When you have set the variable using something like Set(yourVariable, 1), it will update the value in the status field within your form. Then just use a new save button for the form, which has the following in the OnSelect SubmitForm(YourFormName). This will write the new status value to the SPO list. In the Forms's OnSuccess property, be sure to clear the variable using Set(yourVariable, Blank()). If you use the code in my previous response that will ensure you are showing the correct value when opening an existing record

     

    Hope this helps

     

     

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 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard