1
votes

I am trying to get the data from Netsuite and save it in the salesforce object using Mulesoft Dataweave element alongwith When-Otherwise as per the snippet below, but gives me error:

Could not find a transformer to transform "SimpleDataType{type=java.util.LinkedHashMap, mimeType='/', encoding='null'}" to "CollectionDataType{type=java.util.List, itemType=java.lang.Object, mimeType='/'}".

Not sure how to convert Map to List as I am new to Mulesoft. If I dont use When-Otherwise, it gives:

"Cannot coerce a :null to a :string error" if the value coming from Netsuite is null.

   <dw:transform-message doc:name="Transform Message">
        <dw:set-payload><![CDATA[%dw 1.0
            %output application/java 
            ---
            {
                Some_Id__c: payload.customFieldList.customField[0].StringCustomFieldRef__custbody_reference_id as :string when payload.customFieldList.customField[0].StringCustomFieldRef__custbody_reference_id != null otherwise ""
            } 
            ]]></dw:set-payload>
   </dw:transform-message>
1

1 Answers

1
votes

If you need a list, wrap it in square brackets. Also, try using default instead:

[
  {
    Some_Id__c: payload.customFieldList.customField[0].StringCustomFieldRef__custbody_reference_id as :string default ""
  }
]