dataweave

how to convert yyyymmdd into mm-dd-yyyy in dataweave

穿精又带淫゛_ 提交于 2019-12-25 07:59:12
问题 I have two string 1 represent date and 2nd time. have to convert same into date format in Mule-dataweave input :- s1= 20161228(yyyymmdd), s2= 1608(hhmm) output :- 12-28-2016 16:08:00(mm-dd-yyyy hh:mm:ss) in date format. Any Help? 回答1: This should work %dw 1.0 %output application/java %var s1= 20161228 // (yyyymmdd), %var s2= 1608 //(hhmm) --- output : (s1 ++ s2) as :localdatetime {format:"yyyyMMddHHmm"} as :string {format:"MM-dd-yyyy HH:mm:ss"} Hope this helps. 回答2: { "data":payload.date as

Custom Lookup in dataweave

房东的猫 提交于 2019-12-25 04:40:29
问题 I have 2 field in the input, one is primary_language & the other is secondary_language. I have a case where I have to lookup values present in these two fields and then return a specific value according to the table. For example If primary language is English & secondary language is null then English will be the output & if primary language is Spanish & secondary is Sign then put None in the output & so on. Can one tell how we can perform this in dataweave in mulesoft. 回答1: Do you really have

How do you accumulate values within a ForEach loop in Mule?

一世执手 提交于 2019-12-25 03:32:14
问题 I have the below json output: { "results": [ { "ID": "1", "ImageID": "2", "Name": "Test1", "Owner": "sysadmin", "Author": "sysadmin", "Creator": "sysadmin" }, { "ID": "2", "ImageID": "23", "Name": "Test2", "Owner": "sysadmin", "Author": "sysadmin", "Creator": "sysadmin" } ] } For each ID in above response, i need to invoke the rest service passing ID as a parameter and the rest service will send me a response back. I have to consolidate all the output into a single json response in mule. I

How do you accumulate values within a ForEach loop in Mule?

只愿长相守 提交于 2019-12-25 03:32:01
问题 I have the below json output: { "results": [ { "ID": "1", "ImageID": "2", "Name": "Test1", "Owner": "sysadmin", "Author": "sysadmin", "Creator": "sysadmin" }, { "ID": "2", "ImageID": "23", "Name": "Test2", "Owner": "sysadmin", "Author": "sysadmin", "Creator": "sysadmin" } ] } For each ID in above response, i need to invoke the rest service passing ID as a parameter and the rest service will send me a response back. I have to consolidate all the output into a single json response in mule. I

Validation of Payload in ESB

只愿长相守 提交于 2019-12-24 07:19:35
问题 I have a HTTP POST REQUEST which sends a payload as follows: { "key1" : "value1", "key2" : "value2" ,"key3": "value3" } I was able to validate all the values but I had to use a component everytime. In this case , I used the validator "Not a blank string" 3 times. 1. Is there any way that I can validate all the three values in a single validator ? 2. Should I use Scatter-Gather for validating all the values in parallel(according to best-practices) ? 3. How can I validate the key set(the key

Mule Dataweave format :number

我们两清 提交于 2019-12-24 00:58:53
问题 I'm having an issue trying to parse a string to double this would be a sample code, it's returning an integer instead of type :double any ideas? { "data": "22" as :number { format: "##.##" } } 回答1: This, and only this, works for me; %dw 1.0 %output application/json --- { data: "22" as :number as :string {format: ".00"} as :number } format only seems to add zeros when converting from a number to a string. If "22" would have already been a number you wouldn't need the first :number conversion;

Dynamic Key Value Pair in DataWeave

回眸只為那壹抹淺笑 提交于 2019-12-23 10:54:43
问题 DataWeave doesn't like what I'm trying to do with it, and I'm not sure if I'm doing something wrong, or if it is a limitation of DataWeave that isn't possible. Here's the scenario: I'm querying Salesforce and getting two values back: lets call them X and Y. Here's the return I want [{X:Y}, {X2:Y2}, {X3:Y3}, ...] however, using DataWeave it doesnt seem possible to get a key value pair like that, instead, it only seems possible to specifically set the Key for each value in the script like so: [

xml to List conversion in mule esb using data weave component

夙愿已清 提交于 2019-12-14 03:17:43
问题 I have the following xml as my input InputXML: <Orders> <Order> <sample id="1"></sample> <sample id="2"></sample> . . . . </Order> <Order> <sample id="1"></sample> <sample id="2"></sample> . . . . </Order> <Order> <sample id="1"></sample> <sample id="2"></sample> . . . . </Order> . . . . </Orders> I need to send this xml to the batch component in my flow. My batch should accept each record in the following manner Record1:1st Order Record2:2nd Order Record3:3rd Order . . . . Now please let me

Aggregate two payloads in Mule ESB

我的未来我决定 提交于 2019-12-13 07:36:10
问题 My mule code is hitting two tables and getting some details. First one is order details, which I am storing in a flow variable i.e order and another database is returning order item details which I am storing in orderitem variable. I want to aggregate both the payload based on one condition. Every orderId has order items (which is stored in flowVars.orderitem) and map these order items to respective orderID. flowVars.order value is as below [{partnerId=e83185e9f33e4234ba9eaa81dba515ad,

Converting CSV to array using DataWeave

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 05:25:54
问题 I'm using Mule Requester to load a CSV file. After the file is loaded, the payload is a byte array, which I store in a flow variable, mycsv . I keep getting an exception. org.mule.api.MessagingException: Exception while executing: NetIds: flowVars.mycsv map $."My Column Name" ^ Cannot coerce a :binary to a :array (com.mulesoft.weave.mule.exception.WeaveExecutionException). Message payload is of type: byte[] Here's my DataWeave code: %dw 1.0 %output application/java --- { Values: flowVars