gpt4 book ai didi

java - 从 JAVA 在线调用 Microsoft Dynamics CRM 2011

转载 作者:行者123 更新时间:2023-12-01 04:56:17 25 4
gpt4 key购买 nike

我正在通过 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 和“帐户”填写字段 parentcustomeridparentcustomeridtype,但联系人没有与帐户关联。

最佳答案

要设置选项列表值,您必须使用 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 - 从 JAVA 在线调用 Microsoft Dynamics CRM 2011,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14072828/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com