[英]MuleSoft NetSuite Connector Search
I am trying to figure out how to get values from the returned Search payload using the NetSuite Connector in Mulesoft. 我试图弄清楚如何使用Mulesoft中的NetSuite Connector从返回的Search有效负载中获取值。
Whenever I use this connector, it returned an output of List<Map<String, Object>>
, I am unsure if there is a way to use DataWeave and map the values returned, because of this type of output. 每当我使用此连接器时,由于这种类型的输出,我都不确定是否有一种方法可以使用DataWeave并映射返回的值,因此它会返回
List<Map<String, Object>>
的输出。
Is there a way to actually get the components of this List, and map it to something else using Dataweave? 有没有一种方法可以真正获取此List的组件,并使用Dataweave将其映射到其他对象?
In one example, I am grabbing the internalId of a search result record using #[payload.hasNext() ? 'Employee Found: ' + payload.next().get('internalId') : 'Employee Not Found']
在一个示例中,我使用
#[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']
and I can successfully get the value. #[payload.hasNext() ? 'Employee Found: ' + payload.next().get('internalId') : 'Employee Not Found']
,我可以成功获取该值。
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. 在另一种尝试将内部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"/>
ERROR: 错误:
Message : Failed to invoke getRecord.
消息:无法调用getRecord。 Payload
有效载荷
: org.mule.streaming.ConsumerIterator@20969555 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):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上的“未知源”(未知源)
You can get the values and pass it inside a batch execute and do the mapping inside the batch 您可以获取值并将其传递到批处理中,并在批处理中进行映射
<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>
Mapping Inside batch 映射内部批次
<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">
Is there a way to actually get the components of this List, and map it to something else using Dataweave?
有没有一种方法可以真正获取此List的组件,并使用Dataweave将其映射到其他对象?
It is currently not possible. 目前不可能。 The Search operation returns a list of
Map<String, Object>
without any additional metadata thus making it impossible for DataWeave to identify which components are included. Search操作返回
Map<String, Object>
的列表,而没有任何其他元数据,因此DataWeave无法识别其中包括的组件。 I'm not sure if this responds to a limitation of the NetSuite SOAP API or it just hasn't been implemented in the connector. 我不确定这是否响应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.
在另一种尝试将内部ID与NetSuite连接器“获取记录”功能一起使用的情况下,我尝试以相同的方式输入内部ID参数有效负载.next()。get('internalId'),并得到如下错误。
The Search operation works because it is a paginated operation that wraps the payload inside a ConsumerIterator
object. 搜索操作之所以有效,是因为它是一个分页的操作 ,将有效载荷包装在
ConsumerIterator
对象内。 However, the Get Record is NOT paginated and just returns a Map<String, Object>
. 但是, 获取记录未分页,仅返回
Map<String, Object>
。 Therefore, you should be able to obtain the value by calling payload.get('internalId')
. 因此,您应该能够通过调用
payload.get('internalId')
获得该值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.