将picklist值发送到DynamicsCRM在线,以使用soap-php创建潜在客户



我正在尝试使用php中的soap在线创建crm 365的潜在客户。我可以通过发送soap请求成功创建潜在客户,但我也想发送潜在客户来源,这是crm中的一个选择列表。这是我在php中的代码。不确定要使用哪种数据类型,int32或picklist,但两者都不起作用。

<b:KeyValuePairOfstringanyType>
<c:key>leadsourcecode</c:key>
<c:value i:type="d:OptionSetValue" xmlns:d="http://www.w3.org/2001/XMLSchema">100000010</c:value>
</b:KeyValuePairOfstringanyType>';

我得到这个错误:

Sendera:DeserializationFailedThe formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://schemas.microsoft.com/xrm/2011/Contracts/Services:entity. The InnerException message was 'Error in line 22 position 82. Element 'http://schemas.datacontract.org/2004/07/System.Collections.Generic:value' contains data from a type that maps to the name 'http://www.w3.org/2001/XMLSchema:OptionSetValue'. The deserializer has no knowledge of any type that maps to this name. Consider changing the implementation of the ResolveName method on your DataContractResolver to return a non-null value for name 'OptionSetValue' and namespace 'http://www.w3.org/2001/XMLSchema'.'. Please see InnerException for more details.

内部值标记需要一个大写V。以下是我用来更新状态原因并根据需要进行修改的代码。此外,SOAP端点已弃用,您应该转到WebAPI

request += "<a:KeyValuePairOfstringanyType>";
request += "<c:key>Status</c:key>";
request += "<c:value i:type="a:OptionSetValue">";
request += "<a:Value>" + 2 + "</a:Value>";
request += "</c:value>";
request += "</a:KeyValuePairOfstringanyType>";

你能试试这个吗?

<a:keyvaluepairofstringanytype>
<b:key>leadsourcecode</b:key>
<b:value i:type="a:OptionSetValue">
<a:value>100000010</a:value>
</b:value>
</a:keyvaluepairofstringanytype>

最新更新