码迷,mamicode.com
首页 > 其他好文 > 详细

CRM 客户端程序开发:获取表单界面上各种字段的值及其他属性

时间:2016-06-13 11:52:03      阅读:1234      评论:0      收藏:0      [点我收藏+]

标签:dynamics crm 表单 编程 获取值

我们写程序常用的就是获取字段的值,对于不同的字段类型,通过getValue() 获取到的值如下,这个表摘自SDK中的 Xrm.Page.data.entity attribute (client-side reference) 章节。


Attribute Type

Return Type

boolean

Boolean

datetime

Date

To get the string version of a date using the Microsoft Dynamics CRM user’s locale preferences, use the format and localeFormat methods. Other methods will format dates using the operating system locale rather than the user’s Microsoft Dynamics CRM locale preferences.

decimal

Number

double

Number

integer

Number

lookup

Array

An array of lookup objects.

Note

Certain lookups allow for multiple records to be associated in a lookup, such as the To: field for an e-mail entity record. Therefore, all lookup data values use an array of lookup objects – even when the lookup attribute does not support more than one record reference to be added.

Each lookup has the following properties:

entityType

String: the name of the entity displayed in the lookup

id

String: The string representation of the GUID value for the record displayed in the lookup.

name

String: The text representing the record to be displayed in in the lookup.

memo

String

money

Number

optionset

Number

string

String

 

我具体通过下面的代码来演示各种字段获取值得方法:


elseif(Xrm.Page.ui.getFormType()==2){//打开现有记录来修改
Xrm.Page.data.entity.attributes.forEach(
function(attribute, index){
var attrType = attribute.getAttributeType();
switch(attrType)
{
case"boolean":
                           alert("字段类型:两个选项;\n字段逻辑名称:"+ attribute.getName()+":\n字段必输属性:"+ attribute.getRequiredLevel()+";\n提交属性:"+ attribute.getSubmitMode()+";\n值是否修改过:"+ attribute.getIsDirty()+"\n值:"+ attribute.getValue());
break;
case"datetime":
                           alert("字段类型:日期和时间;\n字段逻辑名称:"+ attribute.getName()+":\n字段必输属性:"+ attribute.getRequiredLevel()+";\n提交属性:"+ attribute.getSubmitMode()+";\n值是否修改过:"+ attribute.getIsDirty()+"\n值:"+ attribute.getValue());
break;
case"decimal":
                           alert("字段类型:十进制数;\n字段逻辑名称:"+ attribute.getName()+":\n字段必输属性:"+ attribute.getRequiredLevel()+";\n提交属性:"+ attribute.getSubmitMode()+";\n值是否修改过:"+ attribute.getIsDirty()+"\n值:"+ attribute.getValue());
break;
case"double":
                           alert("字段类型:浮点数;\n字段逻辑名称:"+ attribute.getName()+":\n字段必输属性:"+ attribute.getRequiredLevel()+";\n提交属性:"+ attribute.getSubmitMode()+";\n值是否修改过:"+ attribute.getIsDirty()+"\n值:"+ attribute.getValue());
break;
case"integer":
                           alert("字段类型:整数;\n字段逻辑名称:"+ attribute.getName()+":\n字段必输属性:"+ attribute.getRequiredLevel()+";\n提交属性:"+ attribute.getSubmitMode()+";\n值是否修改过:"+ attribute.getIsDirty()+"\n值:"+ attribute.getValue());
break;
case"lookup":
                           alert("字段类型:查找;\n字段逻辑名称:"+ attribute.getName()+":\n字段必输属性:"+ attribute.getRequiredLevel()+";\n提交属性:"+ attribute.getSubmitMode()+";\n值是否修改过:"+ attribute.getIsDirty()+"\n显示值:"+ attribute.getValue()[0].name +";选择记录ID"+ attribute.getValue()[0].id +"选择记录逻辑名称:"+ attribute.getValue()[0].entityType);
break;
case"memo":
                           alert("字段类型:多行文本;\n字段逻辑名称:"+ attribute.getName()+":\n字段必输属性:"+ attribute.getRequiredLevel()+";\n提交属性:"+ attribute.getSubmitMode()+";\n值是否修改过:"+ attribute.getIsDirty()+"\n值:"+ attribute.getValue());
break;
case"money":
                           alert("字段类型:货币;\n字段逻辑名称:"+ attribute.getName()+":\n字段必输属性:"+ attribute.getRequiredLevel()+";\n提交属性:"+ attribute.getSubmitMode()+";\n值是否修改过:"+ attribute.getIsDirty()+"\n值:"+ attribute.getValue());
break;
case"optionset":
                           alert("字段类型:选项集;\n字段逻辑名称:"+ attribute.getName()+":\n字段必输属性:"+ attribute.getRequiredLevel()+";\n提交属性:"+ attribute.getSubmitMode()+";\n值是否修改过:"+ attribute.getIsDirty()+"\n选择值:"+ attribute.getValue()+"选择文本:"+ attribute.getText());
break;
case"string":
                           alert("字段类型:单行文本;\n字段逻辑名称:"+ attribute.getName()+":\n字段必输属性:"+ attribute.getRequiredLevel()+";\n提交属性:"+ attribute.getSubmitMode()+";\n值是否修改过:"+ attribute.getIsDirty()+"\n值:"+ attribute.getValue());
break;
default:
                           alert("未知");
}
});
}


效果如下,需要注意查找字段获取值得分析。

技术分享 
技术分享
技术分享
 技术分享 技术分享 技术分享
技术分享
技术分享 技术分享
技术分享  技术分享 技术分享 技术分享 技术分享 


CRM 客户端程序开发:获取表单界面上各种字段的值及其他属性

标签:dynamics crm 表单 编程 获取值

原文地址:http://wenzengliu.blog.51cto.com/9378751/1788532

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!