I want to remove the objects from the list whose profile is Aftersales_Manager and raflag is false but I'm facing and issue in DataWeave 1.0 in Mule 3. Please suggest the correct DataWeave code in Mule 3.
%dw 1.0
%output application/json
---
payload filter ($.raflag != false and $.mule_temp_profile ='Aftersales_Manager')
map {
"ldap": $.ldap,
"status": $.status,
"m_value": $.m_value,
"raflag": $.raflag,
"profile": $.profile
}
Input:
[{
"ldap": "V00075",
"raflag": true,
"profile": "Aftersales_Manager"
}, {
"ldap": "V00076",
"raflag": true,
"profile": "Aftersales_Manager"
}, {
"ldap": "V00077",
"raflag": false,
"profile": "Aftersales_Manager"
}, {
"ldap": "V00078",
"raflag": true,
"profile": "Worker"
}, {
"ldap": "V00079",
"raflag": true,
"profile": "Manager"
}]
Expected output:
[{
"ldap": "V00075",
"raflag": true,
"profile": "Aftersales_Manager"
},
{
"ldap": "V00076",
"raflag": true,
"profile": "Aftersales_Manager"
},
{
"ldap": "V00078",
"raflag": true,
"profile": "Worker"
},
{
"ldap": "V00079",
"raflag": true,
"profile": "Manager"
}
]
Your input doesn't has a mule_temp_profile
. I suspect you meant profile
. And there is no need to compare raflag
to false because it is already a boolean. The map is also unneeded, since you are outputting the same key-values after all.
%dw 1.0
%output application/json
---
payload filter ($.raflag or $.profile !='Aftersales_Manager')
Output:
[
{
"ldap": "V00075",
"raflag": true,
"profile": "Aftersales_Manager"
},
{
"ldap": "V00076",
"raflag": true,
"profile": "Aftersales_Manager"
},
{
"ldap": "V00078",
"raflag": true,
"profile": "Worker"
},
{
"ldap": "V00079",
"raflag": true,
"profile": "Manager"
}
]