2017-02-15 102 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">