2017-07-24 70 views
0

我查询salesforce联系人对象中的数据(10-20条记录),并从中获取id值到变量中。要做到这一点,我设置有效载荷为#[org.apache.commons.collections.IteratorUtils.toList(有效载荷)],但无法正常工作。如何将salesforce选择查询响应转换为mule中的可读格式?

PFB是示例代码:

<flow name="SetFunctionRole-table"> 
     <sfdc:query config-ref="SFA_NOL_CLOUDHUB2" query="dsql:SELECT Id, AccountId,Account_BP_ID__c,Account_BT_Code__c,Birthdate,Department,Email,Fax,FirstName,LastName,MiddleName,MobilePhone,Name FROM Contact WHERE AccountId = '#[flowVars.varCustomer_Id]' ORDER BY AccountId ASC" doc:name="get contacts from AccountId"/> 
     <logger message="#[payload]" level="INFO" doc:name="Logger"/> 
     <set-payload value="#[org.apache.commons.collections.IteratorUtils.toList(payload)]" doc:name="Set Payload"/> 
     <foreach collection="#[payload]" doc:name="For Each"> 
      <logger message="#[payload]" level="INFO" doc:name="Logger"/> 
      <set-variable variableName="varContact_id" value="#[payload['Id']]" doc:name="Variable"/> 
      <sfdc:query-single config-ref="SFA_NOL_CLOUDHUB2" query="dsql:SELECT Function__c,Id FROM Contact_Function_Role__c WHERE Contact__c = '#[flowVars.varContact_id]'" doc:name="Salesforce"/> 
      <logger message="#['Inserting key:' + flowVars.varContact_id + ' and value: ' + payload.Id]" level="INFO" doc:name="Logger"/> 
      <objectstore:store config-ref="ObjectStore__Connector" key="#[flowVars.varContact_id]" value-ref="#[payload.Id]" overwrite="true" doc:name="ObjectStore"/> 
     </foreach> 
    </flow> 

获得以下错误消息,在设定的有效载荷:

ERROR 2017-07-24 20:05:50,333 [[ws21.2-prod].SetFunctionRole-table.stage1.02] org.mule.exception.DefaultMessagingExceptionStrategy: 
******************************************************************************** 
Message    : Execution of the expression "org.apache.commons.collections.IteratorUtils.toList(payload)" failed. (org.mule.api.expression.ExpressionRuntimeException). 
Payload    : [email protected] 
Payload Type   : org.mule.streaming.ConsumerIterator 
Element    : /SetFunctionRole-table/processors/2 @ ws21.2-prod:create-prospect.xml:177 (Set Payload) 
Element XML   : <set-payload value="#[org.apache.commons.collections.IteratorUtils.toList(payload)]" doc:name="Set Payload"></set-payload> 
-------------------------------------------------------------------------------- 
Root Exception stack trace: 
[UnexpectedErrorFault [ApiFault exceptionCode='INVALID_OPERATION_WITH_EXPIRED_PASSWORD' 
exceptionMessage='The users password has expired, you must call SetPassword before attempting any other API operations' 
extendedErrorDetails='{[0]}' 
] 
] 

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) 

回答

1

你为什么试图将有效载荷是这样的“创意”的方式,没有必要也不会工作。

SalesForce连接器输出的类型为org.mule.streaming.ConsumerIterator,可以通过For Each范围直接读取,因此这已经是一个集合。

删除设置有效负载,看看是否有效,如果你调试你应该看到的行为,我刚刚测试过,这个工程。

相关问题