perform null check in Dataweave

 

isEmpty is a dataweave core function that can be used to perform null check In Mule 4.

It works on Array,String and Object and gives the result accordingly

Examples:

%dw 2.0
output application/json
---
[isEmpty([]), isEmpty([123]) ]

Result

[True,false]

Examples:

%dw 2.0
output application/json
---
[ isEmpty(""), isEmpty("string") ]

Result

[True,false]

isEmpty(object)

it will return true if the object is empty else false

Example:

%dw 2.0
output application/json
---
isEmpty({})

Result

true

 

  
Thank you for taking out time to read the above post. Hope you found it useful. In case of any questions, feel free to comment below. Also, if you are keen on knowing about a specific topic, happy to explore your recommendations as well.
 
For any latest updates or posts on our website, you can follow us on LinkedIn. Look forward to connecting with you there.


Share this:
Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Vamsi
Vamsi
8 months ago

Does this work to check date value also? I need to update Salesforce date value from Mule. If you date is empty it should overwrite date field in Salesforce with Null, otherwise with actual value.