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 Pages / How to Control Editabl...
Power Pages
Answered

How to Control Editable Fields in Power Pages Based on Dataverse Data?

(0) ShareShare
ReportReport
Posted on by 16
Hi everyone,
I’m working on a Power Apps Portal and Model-Driven App in a test environment. Currently, I have a setup where an applicant submits an application form through a Power Pages Portal, and this creates a case in Dataverse. Caseworkers manage these cases in a Model-Driven App using a Business Process Flow. If additional information is required, the caseworker can specify which fields in the application need to be updated using an embedded Canvas App. This information is then saved in a column in Dataverse, where the editable fields are stored as an array of field names.
When the applicant returns to the portal to edit their application, only the fields marked by the caseworker as requiring updates should be editable, while all other fields should remain read-only. Currently, this behaviour is achieved by hardcoding the editable fields into the JavaScript running on the portal page.
I would like to replace this with a dynamic approach that fetches the editable fields directly from Dataverse and adjusts the form behaviour accordingly. Specifically, how can I use the JSON data saved in Dataverse to control field editability in the portal? I have some ideas but just not sure if I’m approaching it correctly so any advice or best practices would be greatly appreciated.
Thank you!
Categories:
I have the same question (0)
  • Verified answer
    Fubar Profile Picture
    8,354 Super User 2025 Season 2 on at
    If you are saving the list of fields to the same record, then
    • add the field that holds them to the Form and set it read only and to not show its label.
    • Then in the Power Pages Management App add a Metadata record to the form for the field that is holding the list and specify a CSS class to hide that field.
    • Then use JS to read from the fields from the list
    You say you already hard coded it, so the above should be enough to move you forward.
    You could also use the Web API (but this will be slower as your page needs to load before the call to the API can be made), or retrieve the list by using Liquid on the Web Page in question (bit more tricky if using the modal popups an not the form in a Web Page) and from the LIquid set a Javascript variable.
  • Inogic Profile Picture
    1,135 Super User 2025 Season 2 on at
    Hi,

    To achieve this dynamically, Liquid is used to fetch the editable fields stored in Dataverse, and JavaScript is used to adjust the form behavior accordingly.

    1. Use Liquid to retrieve the editable_fields column (which contains the array of field names) from Dataverse:
                      Liquid

                      {% assign caseId = request.params['caseId'] %}
                      {% assign case = entities.cases[caseId] %}
                      {% assign editableFields = case.editable_fields %}

    ​​​​​​​2. ​​​​​​​Once the editable fields are retrieved, inject them into JavaScript and apply the necessary logic. put the below code in script tag
      
        const editableFields = {{ editableFields | json }};
       
        document.addEventListener("DOMContentLoaded", function() {
            document.querySelectorAll("input, select, textarea").forEach(field => {
                if (editableFields.includes(field.name)) {
                    field.removeAttribute("readonly");
                    field.removeAttribute("disabled");
                } else {
                    field.setAttribute("readonly", "true");
                    field.setAttribute("disabled", "true");
                }
            });
        });



    Hope this helps.
     

    Thanks!

    Inogic Professional Services: Power Platform/Dynamics 365 CRM
    An expert technical extension for your techno-functional business needs
    Service: https://www.inogic.com/services/ 
    Tips and Tricks: https://www.inogic.com/blog/ 

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 Pages

#1
Fubar Profile Picture

Fubar 74 Super User 2025 Season 2

#2
Jerry-IN Profile Picture

Jerry-IN 55

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard