How to reset controls inside Gallery in Canvas App

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com

Lately designing quite a few canvas apps for specific modules and this is one issue we faced recently while working for a customer.

So the customer had a gallery control which was bound to CDS contacts and then there were some additional controls like Checkbox, Text inputs etc for each gallery item where end-users can make their choices.

Advertisements

While the actual screen looked much different, this is the mockup I came up for this scenario.

image

They wanted a reset functionality i,e when the reset button is clicked, the controls inside the gallery should be set back to their default  values. In other words in the example here the text inputs should be cleared and checkboxes should be unchecked.

Piece of cake we thought and out in the code on click of the Reset button

image

Well it didn’t work. And then tried something more stupid

image

Quite obvious, it won’t work. But why? A bit of search but this Microsoft Documentation just helped our understanding. This documentation on PowerApps Reset function is just what we we needed. If you go to the link, you would find this statement – “You cannot reset controls that are within a Gallery or Edit form control from outside those controls. You can reset controls from formulas on controls within the same gallery or form”

Advertisements

Quite obvious, the Reset button was outside the gallery and hence invoking Reset from there didn’t work. But is there a way out? Off-course there is one certainly and much easier than you may think.

So let’s first focus on the text input control inside the gallery item. There is a “Reset” property of the input item.

image

We are going to set it to a context variable however you can use App level variable as well which can be set using “Set” function.

image

You may get an error. that’s fine. This is because we haven’t yet declared the context variable.

Advertisements

Now on-select of the button you can write the below code.

image

Quite understandably, ResetTextInput when set to True, it would reset the text input to it’s default value. However you may ask the question – Why are we setting it to false? The reason for this is for the next operation when you click on the Reset button, it will again change the value from Context variable from false to true. Once a value change is detected by the framework, the Reset function would fire again.

If we don’t set to it to false post reset, it won’t work.

The same you can do for your checkbox. You can use the same variable or a different variable.

A simple one but can save you some time if you are not aware of it.

Advertisements

Hope this helps!

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Our product offerings:

Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)

CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)

Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)

How to show ratings on PowerApps portals/ Dynamics 365 portals. All you need to know

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com

Recently we had this scenario where my customer was trying to configure ratings for a web page in PowerApps portal. Basically it’s a page where customers could login and rate the page content.

So here was the developer who created the web-page and also checked the box “Enable ratings”

image
image

As it occurred, everything should work fine. After all the documentation also mentions that all we need to do is to enable the ratings for the webpage. However the rating control was not visible on the web-page. Seemed like a cache issue and even after restarting the portal, it didn’t show up.

Advertisements

So if you wondering why this happens and kind of stuck, this blog will help you out. To basically show the rating on the page, you need to perform two steps:

Step 1: Enable rating on the content page

For every language a content child page is created for web page in the portal. You would find it in the localized content section of the portal.

image

You would need to open up the page for the specific language and enable ratings for the same.

image
image

Step 2 – Choose the right page template

Advertisements

Now this one can be really hard. Here we have used the Page template provided by the portal which “Page” template. It is to be noted that to show up the ratings control on the web-page, the Page template should be of type Re-write and it should point to ~/Pages/Page.aspx.

image

This can be hard to understand for consultants starting with online portal offering. But for consultants who have past experience of working with ADX controls, there used to be a UserControl called “MultiRatingControl” which we could included in any custom page we develop during those days. The Page.aspx still contains the user control and hence when we use re-write to the specified Page, the rating control shows up.

Advertisements

Old ADX documentation for reference – https://community.adxstudio.com/products/adxstudio-portals/documentation/developers-guide/web-controls/ratings-control/

Hope this helps and save you some time.

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Our product offerings:

Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)

CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)

Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)