dataweave

Mulesoft 3 DataWeave - split a string by an arbitrary length

懵懂的女人 提交于 2021-02-11 07:09:04
问题 In Mule 3 DataWeave, how do I split a long string into multiple lines by a set length? For instance, I have the following JSON input: { "id" : "123", "text" : "There is no strife, no prejudice, no national conflict in outer space as yet. Its hazards are hostile to us all. Its conquest deserves the best of all mankind, and its opportunity for peaceful cooperation many never come again." } The input system can only accept strings of 40 characters or less, so the output XML needs to conform as

Mulesoft 3 DataWeave - split a string by an arbitrary length

删除回忆录丶 提交于 2021-02-11 07:08:50
问题 In Mule 3 DataWeave, how do I split a long string into multiple lines by a set length? For instance, I have the following JSON input: { "id" : "123", "text" : "There is no strife, no prejudice, no national conflict in outer space as yet. Its hazards are hostile to us all. Its conquest deserves the best of all mankind, and its opportunity for peaceful cooperation many never come again." } The input system can only accept strings of 40 characters or less, so the output XML needs to conform as

Mulesoft 3 DataWeave - split a string by an arbitrary length

十年热恋 提交于 2021-02-11 07:08:10
问题 In Mule 3 DataWeave, how do I split a long string into multiple lines by a set length? For instance, I have the following JSON input: { "id" : "123", "text" : "There is no strife, no prejudice, no national conflict in outer space as yet. Its hazards are hostile to us all. Its conquest deserves the best of all mankind, and its opportunity for peaceful cooperation many never come again." } The input system can only accept strings of 40 characters or less, so the output XML needs to conform as

Dataweave 2.0 maxBy and filter

ⅰ亾dé卋堺 提交于 2021-02-10 14:19:40
问题 I'd like to filter an array by a maximum value, and have it return all elements with that value. Dataweave is just returning 1. This is dataweave 2.0 on Mule 4. First, there should be a groupBy to group elements with the same id. Then, within each element group, there should be a search for the largest check_date, and only those within each element group with that date should be returned. %dw 2.0 output application/json var arr = [ { "id": "001P000001MPf0XIAT", "code": "580", "type": "M",

How do I flatten a JSON array to a csv file

时光总嘲笑我的痴心妄想 提交于 2021-02-08 11:30:48
问题 I have an incoming payload in JSON format where I am outputting some of the objects to a CSV file. The payload also has one array: "Chargebacks": [ { "CostCenterCode": "123ABC", "AllocationPercentage": 100 }, { "CostCenterCode": "456DEF", "AllocationPercentage": 100 } ] I need the CSV file to contain: <other headers from the objects>,Cost Center Code 1, Allocation Percentage 1, Cost Center Code 2, Allocation Percentage 2 <other object values>,123ABC,100,456DEF,100 My first attempt was to

How to send a file using http request connector in mule4

倖福魔咒の 提交于 2021-02-08 06:35:34
问题 I am trying to add attachments to JIRA issue using JIRA rest api. I am using mulesoft to develop this flow. But I am not able to figure out how to send a file using request connector in mule 4. JIRA only accepts file in the form of multipart content type. I went through some of the documentation and it seems that till mule 3 using set attachment we can do this. In mule 4 dataweave is used to achieve this functionality but i am not able to find working code that can be used to implement this.

Recursively parse XML to create JSON array using dataweave 2

爱⌒轻易说出口 提交于 2021-01-29 06:49:18
问题 I am trying to parse an XML recursively to create JSON array using dataweave 2 but I am not able to do so. My Input XML is given below - <?xml version="1.0" encoding="UTF-8"?> <Envelope xmlns="http://schemas.microsoft.com/dynamics/2011/01/documents/Message"> <Header> <MessageId>{8736346D-A766-4BE1-8592-C263A4CC2AB5}</MessageId> <Action>http://schemas.microsoft.com/dynamics/2008/01/services/BomBillsofMaterialsService/read</Action> </Header> <Body> <MessageParts xmlns="http://schemas.microsoft

How do you convert SQL Server SELECT into XML in Mule 4?

为君一笑 提交于 2021-01-28 20:23:07
问题 How can I convert the following SQL output into XML using Dataweave in Mule 4? SELECT s.RefId ,s.LocalId ,s.StateProvinceId ,s.SchoolName ,e.Email ,e.EmailType FROM SchoolInfo s LEFT OUTER JOIN SchoolEmail e ON e.SchoolRefId = s.RefId WHERE s.RefId = :ref_id The output in SQL is: RefId LocalId StateProvinceId SchoolName Email Type 7FDF722B-6BBA-4BF0-8205-A5380B269EF1 1 SA Steve's School steven@gmail.com prm 7FDF722B-6BBA-4BF0-8205-A5380B269EF1 1 SA Steve's School test@gmail.com sec The XML

Compare 2 JSON arrays to get matching and un-matching outputs

 ̄綄美尐妖づ 提交于 2021-01-28 13:50:14
问题 I need to compare 2 JSON arrays using Mule 4 dataweave 2.0 to get matching and un-matching outputs. The sample input JSON payload is given below: [ { "CODE": "A11", "NAME": "Alpha", "ID": "C10000" }, { "CODE": "B12", "NAME": "Bravo", "ID": "B20000" }, { "CODE": "C11", "NAME": "Charlie", "ID": "C30000" }, { "CODE": "D12", "NAME": "Delta", "ID": "D40000" }, { "CODE": "E12", "NAME": "Echo", "ID": "E50000" } ] This has to be compared to the below on ID/IDENTITY field. [ { "IDENTITY": "D40000",

How to use groupBy with orderBy on Array to XMl in Mule4

…衆ロ難τιáo~ 提交于 2020-12-16 03:38:09
问题 I having input as Array (json) which needs to groupBy and orderBy with clientId so that its internal Lines are grouped and ordered in to one root in xml (repetitive lines of clientId). I'm stuck how to use dataweave for the XMl response. Please find the request and expected response. Request: [ { "ClientId": 2, "Code": "string", "ReceivedDate": "2018-10-23", "ReceivedTime": "2217", "Warehouse": "30", "Quantity": "20" }, { "ClientId": 1, "Code": "string", "ReceivedDate": "2018-10-23",