Questions tagged [dataweave]

The DataWeave Language is a powerful template engine that allows you to transform data to and from any kind of format (XML, CSV, JSON, Pojos, Maps, etc).

DataWeave is the MuleSoft expression language for accessing and transforming data that travels through a Mule app. DataWeave is tightly integrated with the Mule runtime engine, which runs the scripts and expressions in your Mule app.

DataWeave scripts act on data in the Mule event. Most commonly, you use it to access and transform data in the message payload. For example, after a component in your app retrieves data from one system, you can use DataWeave to modify and output selected fields in that data to a new data format, then use another component in your app to pass on that data to another system.

Full Reference

https://docs.mulesoft.com/mule-user-guide/v/3.7/dataweave-reference-documentation

https://docs.mulesoft.com/mule-runtime/4.2/dataweave

1845 questions
2
votes
1 answer

Need Help in Dataweave

Can someone help me in converting this dataweave to target format ? basically convert the items into array. I even started , but not sure how to proceed further. any suggestions will be helpful payload mapObject(order,key,index) -> { …
Learner
  • 157
  • 2
  • 17
2
votes
1 answer

DW Diff function

I am using the DW diff function to return the differences caused by editing a profile, but there seems to be an issue with what the function returns in the case of nested objects. I need to return both the old value of a field and the new value it…
2
votes
1 answer

convert base64 to byte[] using Dataweave in Mule 4

Getting PDF Attachment from Salesforce as base64 format using Mulesoft like below: toBase64(payload as Binary) But when sending the same payload to NetSuite as File content, giving error. Sending as : write(fromBase64(acc.Body as String) as…
Learner
  • 157
  • 2
  • 17
2
votes
1 answer

Dataweave 1.0 Add Items to Array

My sample payload is given below: { "ID": "72a6dcc0", "SourceCode": "ABC", "TargetCode": "DEF", . . . . . "Products": [ { "ProdId": "410ef294", "ProdDetails": { "ProdIdentifier": "410ef294-e80b", …
2
votes
2 answers

Extract Value From Dynamic JSON payload

I am running Mule 3 and is on dataweave 1.0 I have a JSON payload (with dynamic key and value) which occurs inside a For Each loop. Sample data is given below: { "094d29c7-6abf-4acb-8513-e1d2d2b8998a": "900145600114256" } The key is UUID and…
2
votes
2 answers

Transformation of JSON data in mule 4

I have a requirement wherein I have to convert JSON data from one format to other. I have to fetch corresponding values of JSON array and make them a key value pair. Below are the required details: Input: "Headers": { "Header": [ { …
Manvitha
  • 21
  • 3
2
votes
1 answer

How to calculate minimum in mule

I want to calculate the minimum of vars.a , vars.b , vars.d-vars.c min[vars.a,vars.b,vars.d-vars.c] is not working Math.min(Math.min(vars.a,vars.b),vars.d - vars.c) is also not working I m trying to add this logic in a transform and I am using…
HMT
  • 2,093
  • 1
  • 19
  • 51
2
votes
1 answer

Concatenating two arrays in mule

I am trying to concatenate two arrays: arr1: [{"a":"value"}] arr2: [{"b":"value"}] expected result:[{{"a":"value"},{"b":"value"}}] vars.arr1 ++ vars.arr2 gives an error when arr1 is null. …
HMT
  • 2,093
  • 1
  • 19
  • 51
2
votes
2 answers

Validate the json Array with Either one field required in Mule 4

Request Json Looks like the below :- { "eNumber": 8506493, "details": [ { "id":12345, "name": xyz123 } ] } As part of requirement, I need to check the "details" array that either "id" or "name" field must present.…
Infinity
  • 484
  • 2
  • 8
  • 21
2
votes
2 answers

how to groupBy and map at same transform on dataweave 2?

I have this dataweave 1.0 script that works well: %dw 1.0 %output application/java --- flowVars.worklogs groupBy $.author.accountId map { accountId: $.author.accountId[0], displayName: $.author.displayName[0], timeSpentMinutesMonth: (sum…
mhery
  • 2,097
  • 4
  • 26
  • 35
2
votes
2 answers

What are the uses of $ in dataweave?

I know the typical use case for $ and $$. But, I took a Dataweave course and it was used for something else and I think for this use case it was required for it to be enclosed in parens, i.e. ($). It flattend out the entire object (or something…
Dale
  • 1,289
  • 3
  • 16
  • 36
2
votes
2 answers

Mapping value only in DataWeave 2.0/Mule 4

I'm a bit of a rookie at Mule 4 and have been trying to figure out how to map only the value from an array. My array is: [ { "ssn": "999999991", "contributionCode": "1", "amt": -100.000000 }, { "ssn": "999999991", …
Tek_Datt
  • 25
  • 3
2
votes
1 answer

Concept of default headers in mule

I want to understand the concept of default header in mule.I want to hit a get api call[the code is written in java] from mule and I am sending a token in the header, but I am setting the token in the default header inside the http request…
HMT
  • 2,093
  • 1
  • 19
  • 51
2
votes
1 answer

Extract field from array using DW 1.0 function

I have a session variable called varIP1 which has a value like below: (It's mime type is application/java) {abc={FedId=abc, Id=01FcLA, type=User, Profile={Id=02EmQA, type=Profile, Name=Analyst}}} I am interested in extracting the first Id (01FcLA)…
2
votes
2 answers

Renaming and Deleting attributes in same array using dataweave

My sample input payload is given below: { "entities": [ { "Id": "ab5fdd89e123", "target": { "Data": { "attributes": { "Name": [], "Address": [ { "value": { "AddType": [{"value":…
Triumph Spitfire
  • 663
  • 15
  • 38