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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer Service forum

Javascript to disable all fields on the UCI

(0) ShareShare
ReportReport
Posted on by 64

Hi,

The following Javascript code to disable all fields on the form works for Classic web UI but not for UCI 
if (formContext.getAttribute("apitil_tickettemplate").getValue() != null) {
control.setDisabled(true);
}

Any help would be appreciated!

Thanks,

Shreya K

Categories:
I have the same question (0)
  • Suggested answer
    T.I.A Profile Picture
    1,760 on at

    You could try something like this

       function disableAllFields() {

           formContext.ui.controls.forEach(function (control, i) {

               if (control && control.getDisabled && !control.getDisabled()) {

                   control.setDisabled(true);

               }

           });

       }

    But it may be easier to just make the form read only

  • Shreya kamble Profile Picture
    64 on at

    Hi T.I.A,

    I tried this code but it's not working.

    Thanks,

    Shreya

  • T.I.A Profile Picture
    1,760 on at

    did you get the execution context?

  • Suggested answer
    T.I.A Profile Picture
    1,760 on at

    Sorry I was developing in the browser, here's the complete solution

    function disableAllFields(executionContext) {

       var formContext = executionContext.getFormContext();

       formContext.ui.controls.forEach(function (control, i) {

           if (control && control.getDisabled && !control.getDisabled()) {

               control.setDisabled(true);

           }

       });

    }

    Make sure you get the execution context too

    cont.PNG

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Customer Service

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans