[英]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.