MS CRM - setVisible
Asked Answered
O

4

5

I am newbie with CRM and I was googling for how to hide and show a text field using jScript library in MS CRM (online) and found several options of using the function setVisible.

I tried those options:

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

But only the last one is really working. The first option gives me an error message.

What is the different between them?

Otherwhere answered 19/5, 2013 at 11:11 Comment(0)
P
14

Just to add to the points already made..

The difference between

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

And

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

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

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

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

Which is itself a shortcut from

Xrm.Page.ui.controls.get('new_fieldname').setVisible(false);
Paris answered 21/5, 2013 at 11:14 Comment(0)
S
10

to hide a text field the right method is this:

Xrm.Page.getControl("new_fieldname").setVisible(false);
Subarctic answered 19/5, 2013 at 14:49 Comment(0)
O
4

The attributes are the data, the controls are the HTML Dom objects. You don't tell the data to hide, you tell the control that is displaying the data to hide.

Olecranon answered 19/5, 2013 at 14:53 Comment(0)
R
0

Besides using JavaScript to show/hide field you can use Business Rule to do the same job also CRM platform built to make things easier so when you want to do anything in CRM you must think about it with this order:

  1. Out of the box.
  2. Customization.
  3. Business Rule.
  4. Workflow.
  5. JavaScript.
  6. Plugin-Workflow Activity.
Reshape answered 26/11, 2016 at 12:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.