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 :
Microsoft Dynamics CRM (Archived)

Make an attribute Readonly inside a form

(0) ShareShare
ReportReport
Posted on by 795

Is it possible to loop through all the attributes and make them Readonly except any one attribute after clicking on a ribbon button ?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi,

    You could try registering the following Javascript function on click of the ribbon button.

    function MakeAttributesReadOnlyExceptOne(){
     Xrm.Page.data.entity.attributes.forEach(
      function (attribute, index) {
          var attributeName = attribute.getName();
          if (attributeName == "FieldLogicalName"){ //The field which you do not need to make read only
              Xrm.Page.getControl(attributeName).setDisabled(false);
          }
          else{
              Xrm.Page.getControl(attributeName).setDisabled(true);
          }
      });
    }

    Hope this helps.

  • rath.amit38@gmail.com Profile Picture
    2 on at

    Hi,

    I had implemented a scenario where all the fields on the form were made read-only after the record created.  Please check the below code.

    function disableAllFields() {

       var formType = Xrm.Page.ui.getFormType();

       if(formType!=1)

       {

           Xrm.Page.data.entity.attributes.forEach(function (attribute, index) {

               var control = Xrm.Page.getControl(attribute.getName());

               if (control) {

                   control.setDisabled(true)

               }

           });

       }

    }

    Hope this helps.

    Thanks,

    Amit Kumar Rath.

    MS CRM Consultant

  • CRM Beginner  Profile Picture
    795 on at

    Thanks Sir..It helped!!

  • CRM Beginner  Profile Picture
    795 on at

    Sir @Nithya Gopinath , Can you please clear me a doubt?

  • Nithya Gopinath Profile Picture
    17,078 on at

    @CRM Beginner, Definitely I will try to clear your doubt.

  • CRM Beginner  Profile Picture
    795 on at

    Sir, if i want that on change of an attribute value, my ribbon button 'Submit' and +New  gets invisible and if i use the same entity with the other login, then i can have one more attribute apart from the previous attributes.How is it achieved?

  • Nithya Gopinath Profile Picture
    17,078 on at

    Can you explain your scenario in more detail?

  • CRM Beginner  Profile Picture
    795 on at

    I have a submit ribbon button on a form which i want to hide after i click on it.As on its click,my status attribute value gets "Closed" for the particular entity. So,i want whenever the status value is "Closed ", for that particular records, the "Submit" as well as "New" buttons should not be visible.

  • Verified answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi,

    You could use the Value Rule (in Enable rule) in Ribbon Workbench to hide the ribbon buttons based on the field value in Dynamics CRM.

    See the links below.

    ribbonworkbench.uservoice.com/.../121427-enable-disable-a-ribbon-button-dynamically-based-o

    missdynamicscrm.blogspot.in/.../show-hide-ribbon-based-on-specific-form-in-multiple-forms-crm.html

    Hope this helps.

  • CRM Beginner  Profile Picture
    795 on at

    Yes Sir, it worked.Thanks alot!

    Want one more favour. Can u suggest me how to hide a '+' symbol displayed with a custom view present in dashboard if we have more than one custom views in a dashboard and want to hide the '+' of only one view?

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans