在不使用CRM SDK的情况下检索OptionSet值 [英] Retrieve OptionSet values without using the CRM SDK

查看:88
本文介绍了在不使用CRM SDK的情况下检索OptionSet值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我用于检索联系人实体中属性的CRM OptionSet值的代码。我遇到的问题是我无法使用CRM SDK。我们将在SSIS中部署项目,但我们无权访问GAC来安装SDK。我收到服务执行时的以下错误。



 { 第1行位置错误732.元素'http://schemas.datacontract.org/2004/07/System.Collections.Generic:value'
包含来自a的数据映射到名称http://schemas.microsoft.com/xrm/2011/Metadata:PicklistAttributeMetadata的类型。
反序列化器不知道映射到此名称的任何类型。考虑使用DataContractResolver或添加类型
对应于'PicklistAttributeMetadata'到已知类型列表 - 例如,通过使用KnownTypeAttribute属性
或将其添加到传递给DataContractSerializer的已知类型列表。
}





这是代码片段



 OrganizationRequest request =  new  OrganizationRequest(); 
request.RequestName = RetrieveAttribute;
request.Parameters = new ParameterCollection();

request.Parameters.Add( new KeyValuePair< string,object>( EntityLogicalName,entityLogicalName));
request.Parameters.Add( new KeyValuePair< string,object>( LogicalName,field));
request.Parameters.Add( new KeyValuePair< string,object>( RetrieveAsIfPublished true ));
request.Parameters.Add( new KeyValuePair< string,object>( MetadataId,Guid.Empty));

OrganizationResponse response =(OrganizationResponse)service.Execute(request);





错误发生在最后当响应尝试从服务序列化时行。

解决方案



如果不使用CRM SDK,我们还有一个选项Nuget Package Manager(NPM)

首先,您需要下载并安装该NPM。

然后打开VS并单击新项目,然后您就拥有了动态CRM选项。

然后选择动态CRM包。之后它会询问您的CRM域详细信息。

填写所有凭证和URL详细信息后,您拥有当前解决方案的所有实体。

右键单击各自的实体并选择创建插件选项。

它生成默认的插件代码。编写自己的逻辑并部署插件。

之后进程,插件自动注册相应的实体。

在这里我复制链接下载NPM



https:/ /visualstudiogallery.msdn.microsoft.com/c1eff934-bf97-40a6-bbe3-c25178f18f86 [ ^ ]



希望这可以帮到你。

谢谢

Below is the code i am using to retrieve the CRM OptionSet values of an attribute in the contact entity. The issue i have is that i cannot use the CRM SDK. We will be deploying the project in SSIS and we do not have access to the GAC to install the SDK. I am recieving the following error on the service execution.

{"Error in line 1 position 732. Element 'http://schemas.datacontract.org/2004/07/System.Collections.Generic:value'
contains data from a type that maps to the name 'http://schemas.microsoft.com/xrm/2011/Metadata:PicklistAttributeMetadata'.
The deserializer has no knowledge of any type that maps to this name. Consider using a DataContractResolver or add the type
corresponding to 'PicklistAttributeMetadata' to the list of known types - for example, by using the KnownTypeAttribute attribute
or by adding it to the list of known types passed to DataContractSerializer."}



Here is the code snippet

OrganizationRequest request = new OrganizationRequest();
            request.RequestName = "RetrieveAttribute";
            request.Parameters = new ParameterCollection();

            request.Parameters.Add(new KeyValuePair<string, object>("EntityLogicalName", entityLogicalName));
            request.Parameters.Add(new KeyValuePair<string, object>("LogicalName", field));
            request.Parameters.Add(new KeyValuePair<string, object>("RetrieveAsIfPublished", true));
            request.Parameters.Add(new KeyValuePair<string, object>("MetadataId", Guid.Empty));

            OrganizationResponse response = (OrganizationResponse)service.Execute(request);



The error occurrs on the last line when the response is trying to serialize from the service.

解决方案

Hi,
Without using CRM SDK there is one more option we have that "Nuget Package Manager(NPM)"
First you need to download and Install that NPM.
Then open VS and click new project then you have Dynamic CRM option.
Then select Dynamic CRM package.After that it asks your CRM domain details.
After filling all credential and URL details, you have all entities of your current solution.
Right click on your respective entity and select create plugin option.
It generates default plugin code.Write your own logic and deploy the plugin.
After this process,Plugin Automatically register on respective entity.
Here I copy the link for download NPM

https://visualstudiogallery.msdn.microsoft.com/c1eff934-bf97-40a6-bbe3-c25178f18f86[^]

Hope this helps you.
Thanks


这篇关于在不使用CRM SDK的情况下检索OptionSet值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆