MS CRM - setVisible

I am new to CRM and I searched to find and hide a text field using the jScript library in MS CRM (online) and found several options for using the setVisible function.

I tried these options:

  • Xrm.Page.ui.tabs.get('new_fieldname').setVisible(false);
  • Xrm.Page.data.entity.attributes.get('new_fieldname').setVisible(false);
  • Xrm.Page.getAttribute('new_fieldname').controls.get(0).setVisible(false);

But only the last one works. The first option gives me an error message.

What is the difference between the two?

+4
source share
4 answers

Just add to the already created points.

Difference between

 Xrm.Page.ui.tabs.get('new_fieldname').setVisible(false); 

and

 Xrm.Page.getAttribute('new_fieldname').controls.get(0).setVisible(false); 

The first relates to the tab ( Xrm.Page.ui.tabs ), the second refers to the attribute ( Xrm.Page.getAttribute ).

So, if you want to hide the whole tab, its sections and fields, you can use the first one. If you want to just hide a separate field, you can use

 Xrm.Page.getControl("new_fieldname").setVisible(false); 

Which itself is a shortcut from

 Xrm.Page.ui.controls.get('new_fieldname').setVisible(false); 
+13
source

to hide the text box, the correct method is:

 Xrm.Page.getControl("new_fieldname").setVisible(false); 
+10
source

Attributes are data, controls are objects of an HTML object. You do not specify data to hide, you will inform the control that displays hidden data.

+4
source

In addition to using JavaScript to show / hide the field, you can use the Business rule to do the same work as the CRM platform, created to simplify, so when you want to do something in CRM, you should think about it with this order:

  • From the box.
  • Customization.
  • Business rule.
  • Workflow
  • Javascript
  • Activity plug-in workflow.
0
source

Source: https://habr.com/ru/post/1481613/


All Articles