gpt4 book ai didi

java - 从 Microsoft CRM 2011 Online 检索多个帐户

转载 作者:行者123 更新时间:2023-12-02 00:12:46 35 4
gpt4 key购买 nike

在 Microsoft CRM 2011 在线并使用 Web 服务的情况下,我在 Main.java 中使用以下方法,使用由 Web 服务调用创建的 OrganizationServiceStub 类。检索到的记录数的输出为 -1 有人可以帮助我解决问题。我想检索名称以“Tel”开头的帐户,而不提供 accountid。我可以看到 CRM 中存在数据。谢谢

public static void getAccountDetails(OrganizationServiceStub service, ArrayOfstring fields)
{
try{
ArrayOfanyType aa = new ArrayOfanyType();
aa.setAnyType(new String[] {"Tel"});

ConditionExpression condition1 = new ConditionExpression();
condition1.setAttributeName("name");


condition1.setOperator(ConditionOperator.BeginsWith);
condition1.setValues(aa);

ArrayOfConditionExpression ss = new ArrayOfConditionExpression();
ss.setConditionExpression(new ConditionExpression[] {condition1});

FilterExpression filter1 = new FilterExpression();
filter1.setConditions(ss);

QueryExpression query = new QueryExpression();
query.setEntityName("account");

ColumnSet cols = new ColumnSet();
cols.setColumns(fields);
query.setColumnSet(cols);

query.setCriteria(filter1);

RetrieveMultiple ll = new RetrieveMultiple();
ll.setQuery(query);

RetrieveMultipleResponse result1 = service.retrieveMultiple(ll);

EntityCollection accounts = result1.getRetrieveMultipleResult();

System.out.println(accounts.getTotalRecordCount());
}
catch (IOrganizationService_RetrieveMultiple_OrganizationServiceFaultFault_FaultMessage e) {
logger.error(e.getMessage());
e.printStackTrace();
}
catch (RemoteException e) {
logger.error(e.getMessage());
e.printStackTrace();
}
}

最佳答案

对于 Java,包含此代码片段可解决上述问题

ArrayOfanyType aa = new ArrayOfanyType();   
aa.setAnyType(new String[] {"555"});
ConditionExpression condition1 = new ConditionExpression();

condition1.setAttributeName("telephone1");

condition1.setOperator(ConditionOperator.BeginsWith);
condition1.setValues(aa);

ArrayOfConditionExpression ss = new ArrayOfConditionExpression();
ss.setConditionExpression(new ConditionExpression[] {condition1});

FilterExpression filter1 = new FilterExpression();
filter1.setConditions(ss);

QueryExpression query = new QueryExpression();
query.setEntityName("account");

PagingInfo pagingInfo = new PagingInfo();
pagingInfo.setReturnTotalRecordCount(true);

query.setPageInfo(pagingInfo);

OrganizationServiceStub.ColumnSet colSet = new OrganizationServiceStub.ColumnSet();
OrganizationServiceStub.ArrayOfstring cols = new OrganizationServiceStub.ArrayOfstring();

cols.setString(new String[]{"name", "telephone1", "address1_city"});

colSet.setColumns(cols);

query.setColumnSet(colSet);
query.setCriteria(filter1);

RetrieveMultiple ll = new RetrieveMultiple();
ll.setQuery(query);

OrganizationServiceStub.RetrieveMultipleResponse response = serviceStub.retrieveMultiple(ll);
EntityCollection result = response.getRetrieveMultipleResult();
ArrayOfEntity attributes = result.getEntities();

Entity[] keyValuePairs = attributes.getEntity();

for (int i = 0; i < keyValuePairs.length; i++) {
OrganizationServiceStub.KeyValuePairOfstringanyType[] keyValuePairss = keyValuePairs[i].getAttributes().getKeyValuePairOfstringanyType();
for (int j = 0; j < keyValuePairss.length; j++) {
System.out.print(keyValuePairss[j].getKey() + ": ");
System.out.println(keyValuePairss[j].getValue());
}
}

关于java - 从 Microsoft CRM 2011 Online 检索多个帐户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12382645/

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