[英]MuleSoft NetSuite Connector Search
我試圖弄清楚如何使用Mulesoft中的NetSuite Connector從返回的Search有效負載中獲取值。
每當我使用此連接器時,由於這種類型的輸出,我都不確定是否有一種方法可以使用DataWeave並映射返回的值,因此它會返回List<Map<String, Object>>
的輸出。
有沒有一種方法可以真正獲取此List的組件,並使用Dataweave將其映射到其他對象?
在一個示例中,我使用#[payload.hasNext() ? 'Employee Found: ' + payload.next().get('internalId') : 'Employee Not Found']
來獲取搜索結果記錄的internalId #[payload.hasNext() ? 'Employee Found: ' + payload.next().get('internalId') : 'Employee Not Found']
#[payload.hasNext() ? 'Employee Found: ' + payload.next().get('internalId') : 'Employee Not Found']
,我可以成功獲取該值。
在另一種嘗試將內部ID與NetSuite連接器“獲取記錄”功能一起使用的情況下,我嘗試以相同的方式輸入內部payload.next().get('internalId')
參數payload.next().get('internalId')
,並得到如下錯誤。
<netsuite:get-record config-ref="NetSuite_Login_Auth" internalId="#[payload.next().get('internalId')]" type="EMPLOYEE" doc:name="NetSuite"/>
錯誤:
消息:無法調用getRecord。 有效載荷
:org.mule.streaming.ConsumerIterator@20969555有效負載類型:org.mule.streaming.ConsumerIterator元素:/ streamMigrateAccountToCustomer / processors / 10/0/1/0/1 / searchEmployeeByEntityId / subprocessors / 3/1/0 @ sfdc-netsuite -api元素XML:--------------------------------------------- -----------------------------------根異常堆棧跟蹤:org.mule處的java.util.NoSuchElementException。 org.mule.streaming.ConsumerIterator.next(ConsumerIterator.java:60)處的streaming.AbstractConsumer.consume(AbstractConsumer.java:70)在sun.reflect.DelegatingMethodAccessorImpl.invoke(sun.reflect.GeneratedMethodAccessor148.invoke(Unknown Source)處java.lang.reflect.Method.invoke上的“未知源”(未知源)
您可以獲取值並將其傳遞到批處理中,並在批處理中進行映射
<flow name="swt-ns-data-pull">
<dw:transform-message doc:name="Transform Message">
<dw:set-payload><![CDATA[%dw 1.0
%output application/java
---
{
basic: {
lastModifiedDate: {
operator: "AFTER",
searchValue: flowVars.modifiedDate
},
recordType: {
operator: "IS",
searchValue: "vendorPayment"
}
}
} as :object {
class : "com.netsuite.webservices.transactions.sales.TransactionSearch"
}
]]></dw:set-payload>
</dw:transform-message>
<logger message="started" level="INFO" doc:name="Logger"/>
<netsuite:search config-ref="NetSuite__Request_Level_Token_Based_Authentication" searchRecord="TRANSACTION" bodyFieldsOnly="false" fetchSize="1000" doc:name="NetSuite"/>
</flow>
映射內部批次
<batch:step name="RemittanceDetailCreation">
<json:object-to-json-transformer doc:name="Object to JSON"/>
<batch:set-record-variable variableName="rec" value="#[payload]" doc:name="Record Variable"/>
<dw:transform-message metadata:id="b7f75c92-a6c7-423a-8faa-cb9080914888" doc:name="Transform Message">
<dw:input-payload mimeType="application/json" doc:sample="C:\Users\sathekumar\Desktop\VedorPayment.json"/>
<dw:set-payload><![CDATA[%dw 1.0
%output application/csv header = false
%var NIC=sizeOf payload.applyList.apply
---
payload.applyList.apply map (( payment, indexOfPayment) ->{
NumberInCollection: '"' ++ NIC ++ '"' when NIC != null otherwise null,
ExternalPayableReferenceNumber: null,
ExternalSecondaryPayableReferenceNumber: null,
AdjustmentAmount: null,
DiscountAmount: '"' ++ payment.discAmt ++ '"' when payment.discAmt != null otherwise null,
GrossAmount: '"' ++ (payment.total as :string) ++ '"' when payment.total != null otherwise null,
NetAmount: '"' ++ (payment.amount as :string) ++ '"' when payment.amount != null otherwise null,
PayableDate: payload.PayableDate,
PayableReferenceNumber: paylaod.PR,
PayableType: null,
SecondaryPayableReferenceNumber: null,
SecondaryPayableType: null,
SupplierPayableReferenceNumber: null
})]]></dw:set-payload>
</dw:transform-message>
<byte-array-to-string-transformer doc:name="Byte Array to String"/>
<batch:commit size="1000" doc:name="Batch Commit">
有沒有一種方法可以真正獲取此List的組件,並使用Dataweave將其映射到其他對象?
目前不可能。 Search操作返回Map<String, Object>
的列表,而沒有任何其他元數據,因此DataWeave無法識別其中包括的組件。 我不確定這是否響應NetSuite SOAP API的限制,或者只是尚未在連接器中實現。
在另一種嘗試將內部ID與NetSuite連接器“獲取記錄”功能一起使用的情況下,我嘗試以相同的方式輸入內部ID參數有效負載.next()。get('internalId'),並得到如下錯誤。
搜索操作之所以有效,是因為它是一個分頁的操作 ,將有效載荷包裝在ConsumerIterator
對象內。 但是, 獲取記錄未分頁,僅返回Map<String, Object>
。 因此,您應該能夠通過調用payload.get('internalId')
獲得該值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.