//获取new_name的值(单行文本)
Xrm.Page.getAttribute("new_name").getValue()
//设置new_name的值(单行文本)
Xrm.Page.getAttribute("new_name").setValue("1121")
//获取客户集合(查找)
Xrm.Page.getAttribute("new_accounid").getValue()
//设置客户值(查找)
Xrm.Page.getAttribute("new_accounid").setValue([{entityType: "account",name: "吴泉",id: "{B26F1B26-8F69-E911-B01C-000C29794B17}"}])
//获取选项集的值
Xrm.Page.getAttribute("new_optionset").getValue()
//设置选项集的值
Xrm.Page.getAttribute("new_optionset").setValue(100000001)
//获取多行文本的值
Xrm.Page.getAttribute("new_textarea").getValue()
//设置多行文本的值
Xrm.Page.getAttribute("new_textarea").setValue("我修改值了")
//获取Bool的值
Xrm.Page.getAttribute("new_isornot").getValue()
//设置bool 的值
Xrm.Page.getAttribute("new_isornot").setValue(false)
//获取多项选项集的值
Xrm.Page.getAttribute("new_optionsetlist").getValue()
//设置多项选项集的值
Xrm.Page.getAttribute("new_optionsetlist").setValue([100000001,100000002])
//获取整数的值
Xrm.Page.getAttribute("new_integer").getValue()
//设置整数的值
Xrm.Page.getAttribute("new_integer").setValue(111)
//获取浮点数的值
Xrm.Page.getAttribute("new_double").getValue()
//设置浮点数的值
Xrm.Page.getAttribute("new_integer").setValue(111)
//获取十进制数的值
Xrm.Page.getAttribute("new_decimalnumber").getValue()
//设置十进制数的值
Xrm.Page.getAttribute("new_decimalnumber").setValue(111)
//获取货币的值
Xrm.Page.getAttribute("new_currency").getValue()
//设置货币的值
Xrm.Page.getAttribute("new_currency").setValue(111)
//获取时间和日期的值
Xrm.Page.getAttribute("new_datetime").getValue()
//设置时间和日期的值
Xrm.Page.getAttribute("new_datetime").setValue(new Date("2019-1-1 12:30:12"))
//获取网站相对路径
Xrm.Page.context.getClientUrl()
//获取选项卡以及选项卡里面的子网格
Xrm.Page.ui.tabs.get("tab_5").sections.get("tab_5_section_1");
//设置隐藏显示
setVisible(false)
//设置查找筛选
Xrm.Page.getAttribute("requiredattendees").setLookupTypes(["account"]);
//获取实体主键id
Xrm.Page.data.entity.getId();
//获取实体名称
Xrm.Page.data.entity.getEntityName();
//设置ownerid为当前登录人
Xrm.Page.getAttribute("ownerid").setValue([{ entityType: "systemuser", name: Xrm.Utility.getGlobalContext().userSettings.userName, id: Xrm.Utility.getGlobalContext().userSettings.userId }]);
//刷新页面
var entityFormOptions = {};
entityFormOptions["entityName"] = Xrm.Page.data.entity.getEntityName();
entityFormOptions["entityId"] = Xrm.Page.data.entity.getId();
Xrm.Navigation.openForm(entityFormOptions);
//保存页面
Xrm.Page.data.save();//不会触发保存事件
//表单所有字段锁定
Xrm.Page.ui.controls.get().forEach(function (control) {
if (Xrm.Page.getControl("new_name") != control&&control.getControlType() != "iframe" && control.getControlType() != "webresource"
&& control.getControlType() != "subgrid" && control.getDisabled() == false) {
control.setDisabled(true);
}
});
//获取表单状态
Xrm.Page.ui.getFormType()
//
Xrm.Page.ui.tabs.get("tab_4").getSections().get("tab_4_section_1").controls.get().forEach(function (control) {
control.setDisabled(true);
});
//获取当前窗体名称
Xrm.Page.ui.formSelector.getCurrentItem().getLabel()
//禁用页面
1 Xrm.Page.ui.controls.forEach(function (control, index) { 2 var controlType = control.getControlType(); 3 if (controlType != "iframe" && controlType != "webresource" && controlType != "subgrid")) { 4 control.setDisabled(flag); 5 } 6 });