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

Community site session details

Session Id : hWPdK6YvqbGb1ALvls/m56
Power Apps - Building Power Apps
Answered

Set value by clicking a button, but keep parent.default

Like (0) ShareShare
ReportReport
Posted on 23 Jul 2019 13:39:32 by 969

I'm stuck with SharePoint Forms using variables and parent.default values for a text input field I have called "status". Users can set its value by clicking on buttons.

 

Button1 = "active"
Button2 = "inactive"
Button3 = "cancelled"
Button4 = "expired"
Button5 = "replaced"
Button6 = "in progress"

 

so far so good. However, I'd like the status field to show the Parent.Default whenever the SharePoint item is being opened, but also change whenever the users click on one of these buttons. If it's a new item, the default value for "status" should be "in progress". How can I achieve all of that?

 

Cheers 🙂

 

Categories:
I have the same question (0)
  • mbhatt Profile Picture
    525 on 29 Mar 2023 at 18:39:44
    Re: Set value by clicking a button, but keep parent.default

    Hi @Anonymous  @v-xida-msft 

    I have same problem 

    i created canvas app DataSource from Sharepoint list and there is choice column from list and now for example i have choice column show these 5 category (1 HR departments, 2 is department, asset department, 4 Qa department ,5 Opening department. )now i want to customize like this  i set 2 button on screen 1 which is for create form on screen 2 .  1 button work for 4 categories only and another button work for only 1 category how do i set the formula when i will click on button1 will redirect on new form and only show opening department by default and when i click on button 2 will redirect on same form screen but show me all category ? please suggest me how do is set the formula ? 

  • FabianAckeret Profile Picture
    969 on 24 Jul 2019 at 08:10:50
    Re: Set value by clicking a button, but keep parent.default

    Works great, thank you very much! 🙂

  • Verified answer
    v-xida-msft Profile Picture
    on 24 Jul 2019 at 07:20:21
    Re: Set value by clicking a button, but keep parent.default

    Hi @FabianAckeret ,

    Please consider take a try with the following workaround:

    Set the OnNew property of the SharePointIntegration control to following:

    Set(varStatus, Blank());
    Refresh('YourSPList'); /* <-- Add formula here */
    NewForm(SharePointForm1)

    Set the OnEdit property of the SharePointIntegration control to following:

    Set(varStatus, Blank());
    Refresh('YourSPList'); /* <-- Add formula here */
    EditForm(SharePointForm1)

    Set the OnView property of the SharePointIntegration control to following:

    Set(varStatus, Blank());
    Refresh('YourSPList'); /* <-- Add formula here */
    ViewForm(SharePointForm1)

     

    Please take a try with above solution, check if the issue is solved.

     

    Best regards,

  • FabianAckeret Profile Picture
    969 on 24 Jul 2019 at 07:04:56
    Re: Set value by clicking a button, but keep parent.default

    Thank you @v-xida-msft . That almost seems to work. I'm not sure if this is a SharePoint related issue now, but there is still one error. These are the steps I perform.

     

    1. Edit item

    2. Change status

    3. Save item

    4. Refresh page

    5. Open same item again

     

    When I follow these steps, everything works fine. However, when I skip step 4 (common scenario), I can see the status from step 1, not the one after I saved it in step 3.

    Do you encounter the same problem?

     

  • Verified answer
    v-xida-msft Profile Picture
    on 24 Jul 2019 at 06:27:21
    Re: Set value by clicking a button, but keep parent.default

    Hi @FabianAckeret ,

    Could you please share a bit more about the "status" column in your SP List? Is it a Text type column or a Choice type column?

    Do you want to change the status column value in your Edit form via clicking the 6 buttons, and set default value to "in progress" when open a new form, keep Parent.Default when open a edit form?

     

    Based on the needs that you mentioned, I have made a test on my side, please take a try with the following workaround:

    Set the OnSelect property of the Button1 to following:

    Set(varStatus, "active")

    Set the OnSelect property of the Button2 to following:

    Set(varStatus, "inactive")

    Set the OnSelect property of the Button3 to following:

    Set(varStatus, "cancelled")

    ...

    Set the OnSelect property of the Button6 to following:

    Set(varStatus, "in progress")

     

    Set the OnNew property of the SharePointIntegration control to following:

    Set(varStatus, Blank()); /* <-- Add this formula */
    NewForm(SharePointForm1)

    Set the OnEdit property of the SharePointIntegration control to following:

    Set(varStatus, Blank()); /* <-- Add this formula */
    EditForm(SharePointForm1)

    Set the OnView property of the SharePointIntegration control to following:

    Set(varStatus, Blank()); /* <-- Add this formula */
    ViewForm(SharePointForm1)

     

    1. If the "status" column is a Text type column in your SP List:

    Set the Default property of the Text Input box within the "status" data card within the Edit form to following:

    If(
    !IsBlank(varStatus),
    varStatus,
    If(
    SharePointForm1.Mode = FormMode.New,
    "in progress",
    Parent.Default
    ) )

     

    2.  If the "status" column is a Choice column in your SP List:

    Set the DefaultSelectedItems property of the ComboBox box within the "status" data card in the Edit form to following:

    If(
    !IsBlank(varStatus),
    {
    Value: varStatus
    }
    ,
    If(
    SharePointForm1.Mode = FormMode.New,
    {
    Value: "in progress",
    },
    Parent.Default
    ) )

     

    Please consider take a try with above solution, then check if the issue is solved.

     

    Best regards,

  • Community Power Platform Member Profile Picture
    on 23 Jul 2019 at 17:47:43
    Re: Set value by clicking a button, but keep parent.default

    Another idea is to init the varStatus to default value you want before you show the form. That way you jsut set the card's default value to varStatus. 

  • Community Power Platform Member Profile Picture
    on 23 Jul 2019 at 17:35:30
    Re: Set value by clicking a button, but keep parent.default

    I think you want to use an if statement in the default property. Something like "If (Parent.mode = New, item.status, varStatus)" or init varStaus on the screen's onvisible or similar event to "" and use that in the if statement to decide what the value for the default status should be. 

     

    I also think if you use radio buttons, you can use the radio_button.selected  property in the same way as the variable.

  • FabianAckeret Profile Picture
    969 on 23 Jul 2019 at 14:26:13
    Re: Set value by clicking a button, but keep parent.default

    Let me try to explain:

     

    The "status" field can be any of the mentioned values above. Default is set to "Parent.Default" so whenever I load the item it will show what has been saved previously.

    When I press one of those buttons, the value of the "status" field needs to change accordingly and since I can only change the value of a field with variables, I've set the buttons to something like:

    Button1.OnSelect = "UpdateContext({varStatus:active})"
    Button2.OnSelect = "UpdateContext({varStatus:inactive})"
    Button3.OnSelect = "UpdateContext({varStatus:cancelled})"
    Button4.OnSelect = "UpdateContext({varStatus:expired})"
    Button5.OnSelect = "UpdateContext({varStatus:replaced})"
    Button6.OnSelect = "UpdateContext({varStatus:in progress})"

     

    If I set Status.Default to "varStatus", it won't load Parent.Default anymore on an existing item. 

     

    I hope this clarifies it

  • Community Power Platform Member Profile Picture
    on 23 Jul 2019 at 14:07:34
    Re: Set value by clicking a button, but keep parent.default

    btw, you may want to simply use a radio button (group) rather than creating several buttons. Using radio buttons would make the code easier to maintain as it supports a  "selected" value.

  • Community Power Platform Member Profile Picture
    on 23 Jul 2019 at 14:02:56
    Re: Set value by clicking a button, but keep parent.default

    not sure I fully understand the question but try the Updates property for a form to show values before they are saved. something like control.text = myForm.dataField.Updates.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 637 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 570 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 473

Loading started