locked
Hiding a section on a form RRS feed

  • Question

  • Hi

    I am trying to hide a sction on the appointment entity based on the value of a picklist field that I have created. Can anyone please help me with this.

    Thanks is advance.

    Thursday, April 8, 2010 1:12 PM

Answers

  • Declare Tanguys Toggle function in the onload like this.

    // Tabs and Section Collections are zero based
    ToggleSection = function( tabIndex , sectionIndex , displayType )
    {
    var sec = document.getElementById( "tab" + tabIndex );
    sec.childNodes[0].rows[ sectionIndex ].style.display = displayType;
    }

    and then you can call the ToggleSection function in your onchange event of the picklist.


    MSCRM Bing'd - http://bingsoft.wordpress.com
    • Marked as answer by help23 Thursday, April 8, 2010 2:41 PM
    Thursday, April 8, 2010 1:32 PM
    Moderator
  • But Lassaad is right... You can also try 'inline'... but empty string should work
    My blog : http://mscrmtools.blogspot.com
    You will find:
    Bulk Delete LauncherView Layout replicator
    ISV.Config Manager Form Javascript Manager
    Assembly RecoveryAnd others (use tool tag on my blog)
    • Marked as answer by help23 Thursday, April 8, 2010 2:41 PM
    Thursday, April 8, 2010 2:31 PM
    Moderator
  • try this

    crmForm.all.YOURFIELDNAME_c.parentElement.parentElement.style.display='none';


    Best Regards, Lassaad
    • Proposed as answer by Lassaad.Cabani Thursday, April 8, 2010 1:21 PM
    • Marked as answer by help23 Thursday, April 8, 2010 2:46 PM
    Thursday, April 8, 2010 1:20 PM

All replies

  • Hi,

    You can hide section base on some field on that section please check this for the same

    http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/36503f04-04c6-4267-b0c3-f5f1b7744a2e


    Mahain
    Thursday, April 8, 2010 1:15 PM
    Moderator
  • try this

    crmForm.all.YOURFIELDNAME_c.parentElement.parentElement.style.display='none';


    Best Regards, Lassaad
    • Proposed as answer by Lassaad.Cabani Thursday, April 8, 2010 1:21 PM
    • Marked as answer by help23 Thursday, April 8, 2010 2:46 PM
    Thursday, April 8, 2010 1:20 PM
  • Or use this code related to the index of the tab and section:

    function OnCrmPageLoad() 
    { 
    	//Hide the Second Section in the first Tab. 1st parameter for tab, 2nd parameter for section 
    	ToggleSection( 0 , 1 , "none"); 
    } 
    
    // Tabs and Section Collections are zero based 
    function ToggleSection( tabIndex , sectionIndex , displayType ) 
    { 
    	var sec = document.getElementById( "tab" + tabIndex ); 
    	sec.childNodes[0].rows[ sectionIndex ].style.display = displayType; 
    } 


    My blog : http://mscrmtools.blogspot.com
    You will find:
    Bulk Delete LauncherView Layout replicator
    ISV.Config Manager Form Javascript Manager
    Assembly RecoveryAnd others (use tool tag on my blog)
    Thursday, April 8, 2010 1:21 PM
    Moderator
  • Thanks, in the above Jscript would it be fieldname or section name.
    Thursday, April 8, 2010 1:23 PM
  • one field existing in the section you want to hide
    Best Regards, Lassaad
    Thursday, April 8, 2010 1:25 PM
  • The visibility of the section i want to hide depends on a picklist field which is on another section of the form but same tab.
    Thursday, April 8, 2010 1:27 PM
  • I want to hide the sction based on a picklist value which is on the same tab of the form but different section.
    Thursday, April 8, 2010 1:29 PM
  • Just use my script on the onchange event of your picklist field
    My blog : http://mscrmtools.blogspot.com
    You will find:
    Bulk Delete LauncherView Layout replicator
    ISV.Config Manager Form Javascript Manager
    Assembly RecoveryAnd others (use tool tag on my blog)
    Thursday, April 8, 2010 1:30 PM
    Moderator
  • Just use my script on the onchange event of your picklist field

    My blog : http://mscrmtools.blogspot.com
    You will find:
    Bulk Delete LauncherView Layout replicator
    ISV.Config Manager Form Javascript Manager
    Assembly RecoveryAnd others (use tool tag on my blog)
    Thursday, April 8, 2010 1:30 PM
    Moderator
  • Declare Tanguys Toggle function in the onload like this.

    // Tabs and Section Collections are zero based
    ToggleSection = function( tabIndex , sectionIndex , displayType )
    {
    var sec = document.getElementById( "tab" + tabIndex );
    sec.childNodes[0].rows[ sectionIndex ].style.display = displayType;
    }

    and then you can call the ToggleSection function in your onchange event of the picklist.


    MSCRM Bing'd - http://bingsoft.wordpress.com
    • Marked as answer by help23 Thursday, April 8, 2010 2:41 PM
    Thursday, April 8, 2010 1:32 PM
    Moderator
  • You can try this code :

    if(crmForm.all.YourPicklistfield.DataValue == Condition)

    {

    crmForm.all.YOURFIELDNAME_c.parentElement.parentElement.style.display='none'; //The field existant in the section to hide

    }


    Best Regards, Lassaad
    Thursday, April 8, 2010 1:32 PM
  • You can try this code :

    if(crmForm.all.YourPicklistfield.DataValue == Condition)

    {

    crmForm.all.YOURFIELDNAME_c.parentElement.parentElement.style.display='none'; //The field existant in the section to hide

    }


    Best Regards, Lassaad
    Thursday, April 8, 2010 1:32 PM
  • Thanks all for your help. Just a quick question please, if I want to display the section then would the display property be 'true' rather than 'none'.
    Thursday, April 8, 2010 2:13 PM
  • To display the section :

    crmForm.all.YOURFIELDNAME_c.parentElement.parentElement.style.display='';


    Best Regards, Lassaad
    Thursday, April 8, 2010 2:16 PM
  • Hi Lassaad, The empty string does not work, Throws an error :((.
    Thursday, April 8, 2010 2:26 PM
  • But Lassaad is right... You can also try 'inline'... but empty string should work
    My blog : http://mscrmtools.blogspot.com
    You will find:
    Bulk Delete LauncherView Layout replicator
    ISV.Config Manager Form Javascript Manager
    Assembly RecoveryAnd others (use tool tag on my blog)
    • Marked as answer by help23 Thursday, April 8, 2010 2:41 PM
    Thursday, April 8, 2010 2:31 PM
    Moderator
  • Make sure you use 2 single quites '' not a single double quote ".
    MSCRM Bing'd - http://bingsoft.wordpress.com
    Thursday, April 8, 2010 2:38 PM
    Moderator
  • Thanks Tanguy, it works.
    Thursday, April 8, 2010 2:40 PM