Question Status

Verified
Dilip Gawas asked a question on 10 Feb 2015 5:03 AM

I have used a single field two times in a form. when i hide it using javascript only one control gets hidden and no any change happening to other control. 

code is 

if(Xrm.Page.getAttribute("new_pendinglegaldocs").getValue() == true)
{
hideShowFields("new_describependingdocs", true);
}

Is anyone has idea how to achieve this. help will be appreciated.

Thanks,

Dilip

Reply
Verified Answer
Mathieu LEPOUTRE responded on 10 Feb 2015 5:20 AM

Hi,

You must use controls.forEach

Xrm.Page.getAttribute("new_describependingdocs").controls.forEach(function (control, index)

   {

        control.setVisible(false);

   }

);

Reply
Dilip Gawas responded on 10 Feb 2015 5:28 AM

thanks Mathiew,

Could you please explain what to pass for control and index.

I mean is it out of box function or custom function.

is function("new_describependingdocs",2) is correct statement

Thanks,

Dilip

Reply
Amarsen responded on 10 Feb 2015 5:40 AM

You do not need to pass anything just use the above code and it should work fine. Actually CRM will pass the current control in context i.e. 'new_describependingdocs' and loop through every instance of the control that exists on the form.

Reply
Dilip Gawas responded on 10 Feb 2015 5:43 AM

Yes, It worked. thanks a lot

Reply
Verified Answer
Mathieu LEPOUTRE responded on 10 Feb 2015 5:20 AM

Hi,

You must use controls.forEach

Xrm.Page.getAttribute("new_describependingdocs").controls.forEach(function (control, index)

   {

        control.setVisible(false);

   }

);

Reply