Our writing program is commonly used to get the value of the field, for different field types, the value obtained through GetValue () is as follows, this table is taken from the Xrm.Page.data.entity attribute (client-side Reference) chapter in the SDK.
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 would format dates using the operating system locale rather than the user ' s Microsoft Dynamics CRM locale Pre Ferences. |
decimal |
number |
double |
number |
integer |
number |
Lookup |
Array An array of Lookup objects.
note |
Certain lookups allow for multiple records to being associated in a lookup, such as the To:field for an e-mail entity record . Therefore, all lookup data values use a array of lookup Objects–even when the lookup attribute does is not a support more th A 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 being displayed in the lookup. |
memo |
string |
money |
number |
optionset |
number |
String |
String |
I specifically use the following code to demonstrate the various fields to get the worthwhile method:
ElseIf (Xrm.Page.ui.getFormType () ==2) {//Open existing record to modify
Xrm.Page.data.entity.attributes.forEach (
function (attribute, index) {
var attrtype = Attribute.getattributetype ();
Switch (attrtype)
{
Case "Boolean":
Alert (field type: two options; \ n field logical name: "+ attribute.getname () +": \ n field must lose property: "+ attribute.getrequiredlevel () +"; \ n Commit attribute: "+ Attribute.getsubmitmode () + "; \ n Value modified:" + attribute.getisdirty () + "\ n value:" + attribute.getvalue ());
Break
Case "datetime":
Alert (field type: Date and time; \ n field logical name: "+ attribute.getname () +": \ n field must lose property: "+ attribute.getrequiredlevel () +"; \ n Commit attribute: "+ Attribute.getsubmitmode () + "; \ n Value modified:" + attribute.getisdirty () + "\ n value:" + attribute.getvalue ());
Break
Case "decimal":
Alert (field type: decimal number; \ n field logical name: "+ attribute.getname () +": \ n field must lose property: "+ attribute.getrequiredlevel () +"; \ n Commit attribute: "+ Attribute.getsubmitmode () + "; \ n Value modified:" + attribute.getisdirty () + "\ n value:" + attribute.getvalue ());
Break
Case "Double":
Alert (field type: floating point; \ n Field logical name: "+ attribute.getname () +": \ n field must lose property: "+ attribute.getrequiredlevel () +"; \ n Commit attribute: "+ Attribute.getsubmitmode () + "; \ n Value modified:" + attribute.getisdirty () + "\ n value:" + attribute.getvalue ());
Break
Case "integer":
Alert (field type: integer; \ n field logical name: "+ attribute.getname () +": \ n field must lose property: "+ attribute.getrequiredlevel () +"; \ n Commit attribute: "+ Attribute.getsubmitmode () + "; \ n Value modified:" + attribute.getisdirty () + "\ n value:" + attribute.getvalue ());
Break
Case "Lookup":
Alert ("Field type: Lookup; \ n Field logical name:" + attribute.getname () + ": \ n field must lose property:" + attribute.getrequiredlevel () + "; \ n Commit attribute:" + Attribute.getsubmitmode () + "; \ n Value modified:" + attribute.getisdirty () + "\ n Display Value:" + attribute.getvalue () [0].name + "; Select Record ID" + Attribute.getvalue () [0].id + "Select Record logical Name:" + attribute.getvalue () [0].entitytype];
Break
Case "Memo":
Alert (field type: multiline text; \ n field logical name: "+ attribute.getname () +": \ n field must lose property: "+ attribute.getrequiredlevel () +"; \ n Commit attribute: "+ Attribute.getsubmitmode () + "; \ n Value modified:" + attribute.getisdirty () + "\ n value:" + attribute.getvalue ());
Break
Case ' money ':
Alert (field type: currency; \ n Field logical name: "+ attribute.getname () +": \ n field must lose property: "+ attribute.getrequiredlevel () +"; \ n Commit attribute: "+ Attribute.getsubmitmode () + "; \ n Value modified:" + attribute.getisdirty () + "\ n value:" + attribute.getvalue ());
Break
Case "OptionSet":
Alert (field type: option set; \ n field logical name: "+ attribute.getname () +": \ n field must lose property: "+ attribute.getrequiredlevel () +"; \ n Commit attribute: "+ Attribute.getsubmitmode () + "; \ n Value modified:" + attribute.getisdirty () + "\ n Select value:" + attribute.getvalue () + "Select text:" + Attribute.gettext ());
Break
Case "string":
Alert (field type: Single line of text; \ n field logical name: "+ attribute.getname () +": \ n field must lose property: "+ attribute.getrequiredlevel () +"; \ n Commit attribute: "+ Attribute.getsubmitmode () + "; \ n Value modified:" + attribute.getisdirty () + "\ n value:" + attribute.getvalue ());
Break
Default
Alert ("Unknown");
}
});
}
The results are as follows, and you need to be aware that lookup fields get worth analysis.
650) this.width=650; "alt=" Dynamics CRM client program development: Get the values and other properties of various fields on the form interface-Rayong-Rayong Blog "style=" margin:0 10px 0 0; "src=" Http://img0.ph.126.net/fZX0XXpNKqVVUh0NAPqoLw==/6599289680633719653.png "/>
650) this.width=650; "alt=" Dynamics CRM client program development: Get the values and other properties of various fields on the form interface-Rayong-Rayong Blog "style=" margin:0 10px 0 0; "src=" Http://img0.ph.126.net/3Gmbsjhgc989XQjYx8n5yw==/6599321566470923526.png "/>
650) this.width=650; "alt=" Dynamics CRM client program development: Get the values and other properties of various fields on the form interface-Rayong-Rayong Blog "style=" margin:0 10px 0 0; "src=" Http://img1.ph.126.net/rxNT4XoVnDHa57xZbqTWvA==/6599269889424421492.png "/>
650) this.width=650; "alt=" Dynamics CRM client program development: Get the values and other properties of various fields on the form interface-Rayong-Rayong Blog "src=" http://img2.ph.126.net/ Fy8nhdrbldp0o9w2xkbdcw==/4930315692164208893.png "style=" line-height:28px;margin:0px 10px 0px 0px; "/> 650) this.width=650; "alt=" Dynamics CRM client program development: Get the values and other properties of various fields on the form interface-Rayong-Rayong Blog "style=" margin:0 10px 0 0; "src=" Http://img1.ph.126.net/akK76h-V3MeLA02K8-hHhg==/6608184729701957104.png "/> 650) this.width=650; "alt=" Dynamics CRM client program development: Get the values and other properties of various fields on the form interface-Rayong-Rayong Blog "style=" margin:0 10px 0 0; "src=" Http://img2.ph.126.net/glPRNoSJSxMLa-oFK_wS6Q==/3674374346081179640.png "/>
650) this.width=650; "alt=" Dynamics CRM client program development: Get the values and other properties of various fields on the form interface-Rayong-Rayong Blog "style=" margin:0 10px 0 0; "src=" Http://img1.ph.126.net/aiEiaWNaA_y3B0Ve-gSgAg==/6608261695515899911.png "/>
650) this.width=650; "alt=" Dynamics CRM client program development: Get the values and other properties of various fields on the form interface-Rayong-Rayong Blog "style=" margin:0 10px 0 0; "src=" http://img2.ph.126.net/5A9lGZez4p5aEq2opcAJyg==/6608255098446133367.png "/> 650) this.width=650;" alt= "Dynamics CRM client program development: Get the values and other properties of various fields on the form interface-Rayong-Rayong Blog" style= "margin:0 10px 0 0; "src=" Http://img0.ph.126.net/F7B3oyCFERTQhQYifcZqww==/1422574532396431581.png "/>
650) this.width=650; "alt=" Dynamics CRM client program development: Get the values and other properties of various fields on the form interface-Rayong-Rayong Blog "style=" margin:0 10px 0 0; "src=" http://img2.ph.126.net/S8-VengKEtbJeUTIYK3zbg==/6608206719934512782.png "/> 650) this.width=650;" alt= "Dynamics CRM client program development: Get the values and other properties of various fields on the form interface-Rayong-Rayong Blog" src= "http://img0.ph.126.net/GcuYxyjLgMnkY5giHEjaZA==/ 6599297377215117669.png "style=" line-height:28px;margin:0px 10px 0px 0px; "/> 650" this.width=650; "alt=" Dynamics CRM client program development: Get the values and other properties of various fields on the form interface-Rayong-Rayong Blog "style=" margin:0 10px 0 0; "src=" Http://img1.ph.126.net/zE4aXK04DXbgp2mbpvbzPA==/6608227610655439213.png "/> 650) this.width=650; "alt=" Dynamics CRM client program development: Get the values and other properties of various fields on the form interface-Rayong-Rayong Blog "style=" margin:0 10px 0 0; "src=" Http://img1.ph.126.net/1NTyM0vDA8SXHFgmWci4Ow==/6608251799911249864.png "/> 650) this.width=650; "alt=" Dynamics CRM client program development: Get the values and other properties of various fields on the form interface-Rayong-Rayong Blog "style=" margin:0 10px 0 0; "src=" Http://img1.ph.126.net/eJSJK8JoTLjNh3njdvhbUA==/4946359765836716302.png "/>
CRM client program development: Get the values and other properties of various fields on the form interface