[英]How to convert salesforce select query response into readable format in mule?
我查詢來自salesforce聯系人對象的數據(10-20條記錄),並需要將id值捕獲到變量中。 為此,我將有效負載設置為#[org.apache.commons.collections.IteratorUtils.toList(payload)],但無法正常工作。
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 : org.mule.streaming.ConsumerIterator@665c8b2e
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)
為什么要嘗試以有效方式設置有效載荷,這不是必需的,而且也不起作用。
SalesForce連接器輸出的類型為org.mule.streaming.ConsumerIterator,可以由For Each范圍直接讀取,因此這已經是一個集合。
刪除Set Payload並查看是否有效,如果您進行調試,您應該會看到該行為,我已經對此進行了測試。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.