cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
isabasu
Level: Powered On

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

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 🙂

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Community Support Team
Community Support Team

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

Hi @isabasu ,

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 Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Community Support Team
Community Support Team

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

Hi @isabasu ,

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

9 REPLIES 9
geneZebra
Level 8

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.

geneZebra
Level 8

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.

isabasu
Level: Powered On

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

geneZebra
Level 8

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.

geneZebra
Level 8

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 Support Team
Community Support Team

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

Hi @isabasu ,

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 Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

isabasu
Level: Powered On

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?

 

Community Support Team
Community Support Team

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

Hi @isabasu ,

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

isabasu
Level: Powered On

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

Works great, thank you very much! 🙂

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (4,858)