2017-02-15 110 views
0

我試圖找出如何得到使用Mulesoft NetSuite的連接器返回的搜索有效載荷值。MuleSoft NetSuite的連接器搜索

無論何時使用此連接器,它返回的輸出爲List<Map<String, Object>>,我不確定是否有方法使用DataWeave並映射返回的值,因爲此類型的輸出。

有沒有辦法真正得到名單的組成部分,並使用Dataweave其映射到別的東西?

舉一個例子,我抓住使用#[payload.hasNext() ? 'Employee Found: ' + payload.next().get('internalId') : 'Employee Not Found']搜索結果記錄的internalId,我能順利拿到價值。

在另一種情況下,我嘗試使用NetIdite連接器的「獲取記錄」功能使用internalId,我嘗試以同樣的方式輸入internalId參數payload.next().get('internalId'),並得到如下錯誤。

<netsuite:get-record config-ref="NetSuite_Login_Auth" internalId="#[payload.next().get('internalId')]" type="EMPLOYEE" doc:name="NetSuite"/> 

錯誤:

Message : Failed to invoke getRecord. Payload
: [email protected] Payload Type : org.mule.streaming.ConsumerIterator Element : /streamMigrateAccountToCustomer/processors/10/0/1/0/1/searchEmployeeByEntityId/subprocessors/3/1/0 @ sfdc-netsuite-api Element XML : -------------------------------------------------------------------------------- Root Exception stack trace: java.util.NoSuchElementException at org.mule.streaming.AbstractConsumer.consume(AbstractConsumer.java:70) at org.mule.streaming.ConsumerIterator.next(ConsumerIterator.java:60) at sun.reflect.GeneratedMethodAccessor148.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source)

回答

0

Is there a way to actually get the components of this List, and map it to something else using Dataweave?

它目前是不可能的。所述搜索操作返回的Map<String, Object>一個列表,而無需任何這樣的附加元數據使它不可能爲了DataWeave識別哪個分量被包括。我不確定這是否響應NetSuite SOAP API的限制,或者它只是沒有在連接器中實現。

In another case where I am trying to use that internalId with the NetSuite Connector 'Get Record' functionality, I try to input an internalId parameter payload.next().get('internalId') the same way and get an error as follows.

搜索操作的工作,因爲它是一個分頁操作一個包裝了ConsumerIterator對象內的有效載荷。但是,獲取記錄未分頁並僅返回Map<String, Object>。因此,您應該可以通過致電​​來獲取價值。

1

你可以得到的值,並將它傳遞一個批次內執行,並做了映射批次內

<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">