[英]Calling Microsoft Dynamics CRM 2011 online from JAVA
我正在通过Java应用程序进行Dynamics CRM集成,并且遵循了CRM培训套件中的示例,并成功地进行了连接和创建客户及联系人的管理。 现在,在创建帐户时以及在将联系人与帐户连接时添加更多字段时遇到了一些问题。 例如,我无法使用作为选择列表的“ address1_freighttermscode”创建帐户。 我的代码如下:
private static OrganizationServiceStub.Guid createAccount(OrganizationServiceStub serviceStub, String[] args) {
try {
OrganizationServiceStub.Create entry = new OrganizationServiceStub.Create();
OrganizationServiceStub.Entity newEntryInfo = new OrganizationServiceStub.Entity();
OrganizationServiceStub.AttributeCollection collection = new OrganizationServiceStub.AttributeCollection();
if (! (args[0].equals("null") )) {
OrganizationServiceStub.KeyValuePairOfstringanyType values = new OrganizationServiceStub.KeyValuePairOfstringanyType();
values.setKey("name");
values.setValue(args[0]);
collection.addKeyValuePairOfstringanyType(values);
}
if (! (args[13].equals("null"))){
OrganizationServiceStub.KeyValuePairOfstringanyType incoterm = new OrganizationServiceStub.KeyValuePairOfstringanyType();
incoterm.setKey("address1_freighttermscode");
incoterm.setValue(args[13]);
collection.addKeyValuePairOfstringanyType(incoterm);
}
newEntryInfo.setAttributes(collection);
newEntryInfo.setLogicalName("account");
entry.setEntity(newEntryInfo);
OrganizationServiceStub.CreateResponse createResponse = serviceStub.create(entry);
OrganizationServiceStub.Guid createResultGuid = createResponse.getCreateResult();
System.out.println("New Account GUID: " + createResultGuid.getGuid());
return createResultGuid;
} catch (IOrganizationService_Create_OrganizationServiceFaultFault_FaultMessage e) {
logger.error(e.getMessage());
} catch (RemoteException e) {
logger.error(e.getMessage());
}
return null;
}
当它执行时,我得到这个错误
[ERROR] Incorrect attribute value type System.String
有没有人有关于如何处理选择列表或查找的示例?
要将联系人与该帐户联系起来,我用该帐户的GUID和“ account”字段填充parentcustomerid
和parentcustomeridtype
字段,但是该联系人未与该帐户关联。
要设置选择列表值,必须使用OptionSet,而对于查找则必须使用EntityReference。 请参阅SDK的C#文档,使用Axis生成的Java代码应以相同的方式工作。
incoterm.setKey("address1_freighttermscode")
//assuming the arg is an integer value that matches a picklist value for the attribute
OptionSetValue freight = new OptionSetValue();
freight.Value = args[13];
incoterm.setValue(freight);
collection.addKeyValuePairOfstringanyType(incoterm);
我使用Java已有十多年了(从未尝试过像Dynamics这样的MS创作),因此它可能与您所喜欢的相去甚远。 :)
您可以使用REST Web服务并直接调用CRM来创建您的实例。 据我所知,它是独立于平台的,并且只要您可以连接到公开的服务OrganizationData ,它就可以正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.