locked
How to hide the label of a field RRS feed

  • Question

  • Hi,

    In MS CRM 2011, how to hide the label of a field in JavaScript?

    For ex, In CRM 4.0, we used to write the below JS code to hide the label of a field.

    crmForm.all.firstname_c.style.display = 'none'

     Kindly help me to get the corresponding code for MS CRM 2011.

     Thanks

    Gopi.R

     

    Friday, April 15, 2011 9:29 AM

Answers

  • Hi,

         You can hide the label using Xrm.Page using following code:

    Xrm.Page.getControl('firstname').setLabel('');
    

      Also you can hide the label using customization:

    1. Open the needed entity

    2. Go to Forms

    3. Open the needed form

    4. Open the properties of field

    5. Uncheck the "Display label on the form"

    6. Click button "Ok"

    7. Click button "Save"

    8. Click button "Publish"

    Monday, April 18, 2011 7:53 AM

All replies

  • Try:-

    Xrm.Page.getControl(attributeName+'_c').setVisible(false);

     

    Also check:-

    http://mscrmblogger.com/2011/02/24/crm-2011-toggle-visibility/


    Regards Faisal
    Friday, April 15, 2011 10:02 AM
  • Thanks Faisal for the reply.

    I'm not getting the control when i use the code as like you mentioned.

    Getting "null" when i use the below code :

    Xrm.Page.getControl('firstname_c')

     

     

     

    Friday, April 15, 2011 10:32 AM
  • Hi,

    This workedfor me

    Xrm.Page.getControl(“VisibleField_CRMFieldSchemaName”).setVisible(true);
    Xrm.Page.getControl(“HiddenField_CRMFieldSchemaName”).setVisible(false);

    Try it

    http://social.microsoft.com/Forums/en/crmdevelopment/thread/516df0a0-1a2d-44e2-b57d-1d199d58fb18


    NarSrav http://www.dynamicsexchange.com
    • Proposed as answer by Nar_mscrm Friday, April 15, 2011 12:10 PM
    Friday, April 15, 2011 12:03 PM
  • Thanks Naresh...

    The code which you shared will change the visibility of the entire field.

    But i need to hide only the label(Display text) of the field.

     

     

     

     

     

     

    Friday, April 15, 2011 2:45 PM
  • Hi,

     

    I hope that help you:

    window.document.getElementById('AttributeName_c').innerText = '';

    Friday, April 15, 2011 3:00 PM
  • Hi,

     

    I already found this below code working fine for hidding the label.

     

    document.getElementById('firstname_c').style.visibility ='hidden';

     

    but, i want to hide the label using Xrm.Page objects. Please advice...

    Monday, April 18, 2011 5:32 AM
  • Hi,

         You can hide the label using Xrm.Page using following code:

    Xrm.Page.getControl('firstname').setLabel('');
    

      Also you can hide the label using customization:

    1. Open the needed entity

    2. Go to Forms

    3. Open the needed form

    4. Open the properties of field

    5. Uncheck the "Display label on the form"

    6. Click button "Ok"

    7. Click button "Save"

    8. Click button "Publish"

    Monday, April 18, 2011 7:53 AM