Skip to main content

Notifications

Announcements

No record found.

Customer Service forum

Javascript to disable all fields on the UCI

Posted on by 62

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:
  • Suggested answer
    T.I.A Profile Picture
    T.I.A 1,760 on at
    RE: Javascript to disable all fields on the UCI

    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

  • T.I.A Profile Picture
    T.I.A 1,760 on at
    RE: Javascript to disable all fields on the UCI

    did you get the execution context?

  • Shreya kamble Profile Picture
    Shreya kamble 62 on at
    RE: Javascript to disable all fields on the UCI

    Hi T.I.A,

    I tried this code but it's not working.

    Thanks,

    Shreya

  • Suggested answer
    T.I.A Profile Picture
    T.I.A 1,760 on at
    RE: Javascript to disable all fields on the UCI

    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

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans