Sitemap

Thursday, October 15, 2015

Get or Set values of all data types using javascript in MS CRM




Single Line of Text or Multi Line of Text:

Set:

Xrm.Page.getAttribute("attribute logical name").setValue("Test");

Get:

Xrm.Page.getAttribute("attribute logical name").getValue();


Two Options:

Set:

Xrm.Page.getAttribute("attribute logical name").setValue(1);

Two options will accept either 1 or 0.

Get:

Xrm.Page.getAttribute("attribute logical name").getValue();

Above code snippet will return “true” in case set value is “1” and “false” if set value is “0”

Xrm.Page.getAttribute("attribute logical name ").getText();

This code snippet will returns the text we have selected.

OptionSet:

Set:

Xrm.Page.getAttribute("attribute logical name").setValue(1);

Get:

Xrm.Page.getAttribute("attribute logical name").getValue();

Above code snippet will return the selected option value.

Xrm.Page.getAttribute("attribute logical name ").getText();

Above code snippet will returns the text of option we have selected.

DateTime:

Set:

Xrm.Page.getAttribute("attribute logical name ").setValue(new Date("12-31-2014"));

Get:

Xrm.Page.getAttribute("attribute logical name ").getValue();


Lookup:

Set:

Xrm.Page.getAttribute("lookupname").setValue([{ id: "record Guid", name: "record name (Optional)", entityType: "entity logical name" }]);


Get:

var lookupVar = Xrm.Page.getAttribute("attribute logical name").getValue();

var ID= lookupVar[0].id;

var Name= lookupVar[0].name;

var LogicalName= lookupVar[0].entityType;


Currency or Decimal:

Set:

Xrm.Page.getAttribute("attribute logical name").setValue("100.00");

Get:

Xrm.Page.getAttribute("attribute logical name").getValue();

No comments:

Post a Comment