2017-02-15 6 views
0

MulesoftのNetSuite Connectorを使用して、返された検索ペイロードから値を取得する方法を理解しようとしています。MuleSoft NetSuite Connector Search

このコネクタを使用するときはいつでも、出力はList<Map<String, Object>>です。このタイプの出力のため、DataWeaveを使用して返される値をマップする方法があるかどうかはわかりません。

このリストのコンポーネントを実際に取得し、Datawaveを使用して別のものにマップする方法はありますか?

例では、検索結果レコードのinternalIdを#[payload.hasNext() ? 'Employee Found: ' + payload.next().get('internalId') : 'Employee Not Found']を使用して取得していますが、値を取得できます。

NetSuite Connectorの「レコードを取得」機能でinternalIdを使用しようとしている別のケースでは、internalIdパラメータpayload.next().get('internalId')を次のように入力してエラーを取得しようとします。

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

ERROR:

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の制限に対応するのか、それとも単にコネクタに実装されていないのかは分かりません。それはConsumerIteratorオブジェクト内のペイロードをラップページ分割操作あるので

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.

検索操作が動作します。しかし、レコードを取得はページ番号付けされず、ちょうどMap<String, Object>を返します。したがって、​​を呼び出して値を取得できるはずです。

1

あなたが値を取得し、バッチ内のマッピングを実行し、実行するバッチ内のバッチ

<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"> 
インサイド

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

マッピングを渡すことができます