我使用下面的ruby gem连接到MS Dynamics CRM API:https://github.com/TinderBox/dynamics_crm。我无法设置任何字段的值,这是一个选项集。使用以下代码:
client.create('lead', firstname: firstName, lastname: lastName, description: description, emailaddress1: email, subject: topic,
companyname: company, telephone1: workPhone, telephone2: homePhone, mobilephone: mobilePhone, description: description,
parentcontactid: customer, customerid: customer, parentaccountid: parent, ownerid: team, campaignid: campaign, leadsourcecode: 4)一切都很好,除了前导源码。它返回一个错误,显示为incorrect attribute type int。我发现选项集有一个名为name的虚拟属性,因此我尝试将leadsourcecode: 4替换为leadsourcecodename: "Partner",并且没有出现错误,但是没有在CRM中设置该值。有没有人知道为什么不设置这个值?
发布于 2015-09-11 04:24:50
这可能是因为我们在属性中使用了错误的对象类型。要在CRM中设置选项集,您需要使用在构造函数中接受int的OptionSetValue。提供直接的int或string将不起作用。
不确定Ruby的等价物,但在C#中应该是这样的:
Entity e = new Entity("my_entity");
e["my_optionsetfield"] = new OptionSetValue(1);https://stackoverflow.com/questions/32506595
复制相似问题