cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JenniferK
Advocate II
Advocate II

update record when 2 form fields refer to the same data field

In my model-driven app I have a Choice field called Likelihood. The choices range from Never to Always. The client wants a slider instead of a dropdown on the record edit form. So I'm creating a custom page. On the page I've added a gallery and hooked it to the Response records. I've added a slider with values of 0 to 5 and a view-only dropdown that shows the corresponding value of Likelihood. This is what it looks like:

JenniferK_0-1642100238620.png

When the form loads, the value of Response.Likelihood (if any) is used to populate both slider.Default and dropdown.Default

//slider.Default
With(ThisItem As ti,LookUp('Risk matrix intersects',Likelihood=ti.Likelihood).'Likelihood score')
//dropdown.Default
ThisItem.Likelihood

When the slider value changes, Response.Likelihood is patched. 

//slider.OnChange
Patch('Responses',ThisItem,{Likelihood:LookUp('Risk matrix intersects','Likelihood score'=Self.Value).Likelihood})

 

Problem 1:  during the patch, the entire gallery may refresh a variable number of times rather than just refreshing the changed record.

Problem 2: at the end of the patch, the record may be something other than the most recent input even though the first of the refreshes definitely showed the desired value momentarily

 

How do I prevent the 'refresh' loop?

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @JenniferK ,

 

Yes, using Radio Control is a good idea. You can use the choices column value Choices(YourList.ChoicesColumnName) as the items of the radio, and only need to modify your formula a little with replacing Slide.Value with Radio.Selected.Value.

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

 

 

Community Support Team _ Jeffer Ni

If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

3 REPLIES 3
v-jefferni
Community Support
Community Support

Hi @JenniferK ,

 

Since you have append the Patch function on the OnChange property of the slider control, every time a user change the slider value it will patch to the data source once unless the user slides quite fast to the destination by clicking and never change it again. 

 

The best approach of using sliders to update I can imagine would be use a single button to make an one-time submission after confirming all modifications have been done. The formula for OnSelect of the submit button could be like below:

ForAll(Gallery.AllItems, Patch('Responses',ThisRecord,{Likelihood:LookUp('Risk matrix intersects','Likelihood score'=Self.Value).Likelihood}))

 

Hope this helps.

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

Community Support Team _ Jeffer Ni

If this post helps, then please consider Accept it as the solution to help the other members find it.

I agree that the Patch will run on every change and that this is not optimal. But leaving aside the suboptimal nature of potential multiple patches, the client is fairly adamant that no 'Save' button be required. Apparently, their experience is that people forget to click it.

 

I suppose I could use radio buttons. But my experience with radio buttons and Power Apps has not been positive. Any suggestions?

Hi @JenniferK ,

 

Yes, using Radio Control is a good idea. You can use the choices column value Choices(YourList.ChoicesColumnName) as the items of the radio, and only need to modify your formula a little with replacing Slide.Value with Radio.Selected.Value.

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

 

 

Community Support Team _ Jeffer Ni

If this post helps, then please consider Accept it as the solution to help the other members find it.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,226)