Accessing the names of the attributes or controls Xrm.Page object model

1.Access a specific subgrid control by name.

Below function will be written The names of all the subgrid controls
Xrm.Page.ui.controls.get(
function(ctrl,i){
 if(ctrl.getControlType() == "subgrid")
  console.log(ctrl.getName()
  );
});

2. Show the names of all attributes in a form with their type

Xrm.Page.getAttribute(
function (att, i) {
 console.log(att.getName() + " : " + att.getAttributeType())
});

3. Show the valid option values for optionset attributes

Xrm.Page.getAttribute(
function (att, i) {
 if (att.getAttributeType() == "optionset") {
  console.log(att.getName())
  var options = att.getOptions();
  var optionsLength = options.length;
  for (var i = 0; i < optionsLength; i++) {
   var option = options[i];
   console.log("   value: " + option.value + " Label: " + option.text)
  }
 }
});

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s