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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Deny Edit Permission w...
Power Pages
Unanswered

Deny Edit Permission when field value is set to true

(0) ShareShare
ReportReport
Posted on by 3,458 Super User 2024 Season 1

Hi, 

 

Within my page I have a list showing records to authenticated users which are related to them. The users should be able to edit the records via a multi step form. On the last step of the form they need to check a checkbox... After they submit the Form the record should be read only for them. Is this somehow possible? 

Categories:
I have the same question (0)
  • Surendran Ravindran Profile Picture
    212 on at

    Hi @PowerRanger ,

     

    Yes , this is Possible by  javascript 

    Example:

     

     

     <script>
     document.addEventListener("DOMContentLoaded", function() {
     // Check the approval checkbox status 
     function updateFormFields() {
     var approvalCheckbox = document.getElementById("approvalCheckbox");
     var assignedContact = document.getElementById("assignedContact").value;
     var loggedInUser = "JohnDoe"; // Replace with your actual logged-in user
    
     // If the approval checkbox is checked and the user is the assigned contact, make fields read-only
     if (approvalCheckbox.checked && loggedInUser === assignedContact) {
     document.getElementById("readOnlyField1").readOnly = true;
     document.getElementById("readOnlyField2").readOnly = true;
     // Add more fields as needed
     } else {
     // If conditions are not met, make fields editable
     document.getElementById("readOnlyField1").readOnly = false;
     document.getElementById("readOnlyField2").readOnly = false;
     // Add more fields as needed
     }
     }
    
     // Attach the update function to the change event of the approval checkbox
     document.getElementById("approvalCheckbox").addEventListener("change", updateFormFields);
    
     // Call the update function on page load
     updateFormFields();
     });
     </script>

     

     

     

    Regards

    Surendran Ravindran

     

    --------------------------------------------------------------------------------------

    Hope that helps.

    If the post solves your problem, please mark it as solution. If it helps, consider a thumbs up.

     

  • Fubar Profile Picture
    8,514 Super User 2026 Season 1 on at

    Avoid making a whole form readonly via javascript.  Not least of which someone technical can make it editable again.

    • Create a second portal form that is set to be Readonly (or Steps that are readonly).
    • For Lists etc use the Options with fetchxml filter (is set in the Portal/Power Pages Managment App - is not exposed in the designer - and you need to tick the Advanced checkbox to expose this field) to load the Readonly form based on the value being set.  You create 1 option for if the values is not set that will open the edit form, another option for when the value is set that will open the readonly form. https://powerusers.microsoft.com/t5/Power-Apps-Portals/Entity-list-quot-FetchXML-Filter-quot/td-p/717801
    • If loading Web Pages, you need to also watch out for someone bookmarking the url or typing the guid in the the link of an editable page.  To stop this you add Liquid to the page (or Web Template) that checks for the field being set, wrap this around the liquid tag for rendering the form so if ok you load the form else display an error message

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
Valantis Profile Picture

Valantis 41

#2
11manish Profile Picture

11manish 28

#2
sannavajjala87 Profile Picture

sannavajjala87 28 Super User 2026 Season 1

Last 30 days Overall leaderboard