CRM FetchXML activitytypecode结果没有枚举int值 [英] CRM FetchXML activitytypecode Result doesn't have enum int value
问题描述
我有一个JS项目,我想在其中提取CRM活动类型,让用户选择,然后使用所选的活动类型进行另一个fetchxml查询.
我可以使用简单的FetchXML获取活动类型代码的不同列表
<获取版本="1.0" output-format ="xml-platform" mapping =逻辑" distinct ="true"><实体名称="activitypointer"><属性名称="activitytypecode"/></entity></fetch>result.attributes ["activitytypecode"].formattedValue;//返回姓名-'电话'result.attributes ["activitytypecode"].value;//返回字符串-电话
我想要的是枚举的Int32值(例如:电话的4210),例如当我再次使用FetchXML查询时,我需要int32值.
我似乎无法从JavaScript的FetchXML结果中获取它,但是如果使用XrmToolbox,我可以看到int32值.我想念什么?
formattedValue似乎=名称值是文本表示形式,而不是int32
以下是该功能的完整代码:
function GetActivityTypes(){var fetchXML ='<获取版本="1.0" output-format ="xml-platform" mapping =逻辑" distinct ="true">';fetchXML + ='<实体名称="activitypointer">';fetchXML + ='<属性名称="activitytypecode"/>';fetchXML + ='</entity>';fetchXML + ='</fetch>';var结果= XrmServiceToolkit.Soap.Fetch(fetchXML);如果(结果!= null){for(索引= 0;索引< results.length;索引++){var a = results [index] .attributes ["activitytypecode"].formattedValue;//返回活动类型名称-电话var b = results [index] .attributes ["activitytypecode"].value;//返回字符串-电话}}}
我想要的只是活动类型的数值-即:电话= 4120
我使用的是XrmServiceToolKit的最新2.2.1版本.>
从Fetch方法的doRequest内部
var实体= new businessEntity();entity.deserialize(fetchResult.childNodes [ii]);fetchResults.push(entity);
我想知道XrmServiceToolkit中是否还有其他方法可以使用...我什至尝试在自己的FetchRAW方法中进行黑客入侵,以不对结果进行反序列化",但我对JS的了解还不够.出了点问题..我已经成功将Fetch方法用于其他实体数据,
您可以使用WebAPI(Odata),并在其中包含 odata.include-annotations = OData.Community.Display.V1.FormattedValue 使用首选"名称的呼叫标题.
函数retrieveEntity(entityName,Id,columnSet){var serverURL = Xrm.Page.context.getClientUrl();var Query =实体名称+(" + ID +)" + columnSet;var req = new XMLHttpRequest();req.open("GET",serverURL +"/api/data/v8.0/" + Query,true);req.setRequestHeader("Accept","application/json");req.setRequestHeader("Content-Type","application/json; charset = utf-8");req.setRequestHeader("OData-MaxVersion","4.0");req.setRequestHeader("OData-Version","4.0");req.setRequestHeader("Prefer","odata.include-annotations = OData.Community.Display.V1.FormattedValue");req.onreadystatechange = function(){如果(this.readyState == 4/*完成*/){req.onreadystatechange = null;如果(this.status == 200){var data = JSON.parse(this.response);if(data!= null {alert(data ["_ primarycontactid_value@OData.Community.Display.V1.FormattedValue"]);//用于查找文本警报(数据["paymenttermscode@OData.Community.Display.V1.FormattedValue"]);//对于选项集文本}} 别的 {var error = JSON.parse(this.response).error;警报(error.message);}}};req.send();}
http://himbap.com/blog/?p=2077 >
希望有帮助-M.Acosta.D
I have a JS project where I want to pull out the CRM Activity types, let the user select and then do another fetchxml query with the chosen activity types.
I can get distinct list of the activitytypecodes out with simple FetchXML
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="activitypointer" >
<attribute name="activitytypecode" />
</entity>
</fetch>
result.attributes["activitytypecode"].formattedValue; //Returns name - 'Phone Call'
result.attributes["activitytypecode"].value; //Returns string - phonecall
What I want is the Int32 value for the enum (eg: 4210 for Phone Call) for example as when I go to query again with FetchXML I need the int32 value.
I can't seem to get it from the FetchXML results in JavaScript but if I use XrmToolbox - I can see the int32 value.. what am I missing?
The formattedValue seems to = the name And value is a text representation instead of the int32
Here is the complete code for the function:
function GetActivityTypes()
{
var fetchXML = '<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">';
fetchXML += '<entity name="activitypointer" >';
fetchXML += '<attribute name="activitytypecode" />';
fetchXML += '</entity>';
fetchXML += '</fetch>';
var results = XrmServiceToolkit.Soap.Fetch(fetchXML);
if (results != null)
{
for (index = 0; index < results.length; index++)
{
var a = results[index].attributes["activitytypecode"].formattedValue; //returns activity type name - Phone Call
var b = results[index].attributes["activitytypecode"].value; //returns string - phonecall
}
}
}
all i want is the numerical value for the activity type - ie: Phone Call = 4120
I am using the latest 2.2.1 version of the XrmServiceToolKit.. i went hunting around inside there too and noted that inside the 'Fetch' method that as the results are built up, they get' deserialize'd.
From inside the doRequest of the Fetch method
var entity = new businessEntity();
entity.deserialize(fetchResult.childNodes[ii]);
fetchResults.push(entity);
I wonder if there is another method to use inside the XrmServiceToolkit... i even tried hacking in my own FetchRAW method to not 'deserialize' the result but i am not strong enough with JS really.. i surely must be doing something wrong.. i've successfully used the Fetch method for other entity data,
you could use the WebAPI (Odata) and include odata.include-annotations=OData.Community.Display.V1.FormattedValue in the header of the call using the name Prefered.
function retrieveEntity(entityName, Id, columnSet) {
var serverURL = Xrm.Page.context.getClientUrl();
var Query = entityName + "(" + Id + ")" + columnSet;
var req = new XMLHttpRequest();
req.open("GET", serverURL + "/api/data/v8.0/" + Query, true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Prefer", "odata.include-annotations=OData.Community.Display.V1.FormattedValue");
req.onreadystatechange = function() {
if (this.readyState == 4 /* complete */ ) {
req.onreadystatechange = null;
if (this.status == 200) {
var data = JSON.parse(this.response);
if (data != null {
alert(data["_primarycontactid_value@OData.Community.Display.V1.FormattedValue"]); //for lookup text
alert(data["paymenttermscode@OData.Community.Display.V1.FormattedValue"]); //for optionset text
}
} else {
var error = JSON.parse(this.response).error;
alert(error.message);
}
}
};
req.send();
}
http://himbap.com/blog/?p=2077
Hope it helps - M.Acosta.D
这篇关于CRM FetchXML activitytypecode结果没有枚举int值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!