Apisero is now part of NTT DATA - Learn more.

Search
Close this search box.

Dataweave 2.0 Operations in Mule – Part 2

Author: Abhinav Patel

Welcome all to the Dataweave series for Mule 4!

If you have not gone through the previous article, I would recommend you go through it first, to get a basic understanding of Dataweave.  

Requirement:

Considering an e-commerce portal, let’s understand a real-life scenario. The customer adds an item to his car and during checkout, the final amount based on the individual item price is generated.

Let’s say the item list is stored in the backend as an array of JSON objects,

Eg: [ {“itemname”:”Pen”},{“itemname”:”Pencil”},{“itemname”:”Book”}]

and the price list is also stored in  an array of JSON objects

Eg: [{“Pen”:32},{“Pencil”:12}]

There are operations involved to meet the given requirement: 

  1. Once the customer clicks on check out it is required that the final order summary involves the item with price details and if the item is not available in the price list, it should say item_status unavailable.

Let us see how we can meet this requirement.

  1. Now if the customer agrees to buy the products that are available, then we need to filter those items before sending it for invoice generation.

Let us see how to get this done: 

  1. Now let us generate the invoice with the total amount to be paid by the customer

Desirable output: 

Let us see how to reach this phase: 

I hope you got to learn something new from this walkthrough.

Also if you have any use case, feel free to share it at abhinav.patel@apisero.com

Apisero is now NTT DATA

Same dedicated team. Same expertise. Same commitment to driving customer success.

Starting April 1st, Apisero teams and services will operate as NTT DATA Salesforce & MuleSoft Services.

Join us on the next phase of your Digital Transformation journey.

We use cookies on this site to enhance your user experience. For a complete overview of how we use cookies, please see our privacy policy.