Get value of lookup: Xrm.Page.getAttribute("prefix_fieldname").getValue()[0].name
- read method as: get array 0's name (or Id)
Set Value of lookup:
var idValue = "2B0CDF21-7C04-E011-8ABA-00155D011B05"; //GUID of record
var textValue = "Prisliste"; //Name of record
var typeValue = "Pricelevel"; //Schema name of record entity
Xrm.Page.getAttribute("prefix_fieldname").setValue([{id: idValue, name: textValue, entityType: typeValue}]);
Show/hide section: Xrm.Page.ui.tabs.get(1).sections.get("Section_name").setVisible(false)
Set visible values: true or false
Tab value: number (1) or "name"
Section value: "name_of_section"
Show/hide field: Xrm.Page.getControl("prefix_fieldname").setVisible(false)
Set values: true or false
Show/hide tab: Xrm.Page.ui.tabs.get(5).setVisible(false);
Set Values: true or false
Save: Xrm.Page.data.entity.save();
Optional params: "saveandclose" or "saveandnew"
Set Require lvl: Xrm.Page.getAttribute("prefix_fieldname").setRequiredLevel('required');
Get length of string:
var oField = Xrm.Page.getAttribute("prefix_fieldname").getValue();
alert(oField.length);
Substract content of string:
var oField = Xrm.Page.getAttribute("prefix_fieldname").getValue();
alert(oField.substr(0,7);
Ex: "Consultancy" --> after substract: "Consult"
Set Focus:
Xrm.Page.getControl("prefix_fieldname").setFocus(true);
Hope you found this usefull! :)