Input JSON is
[{
"Master_Job__r": {
"Customer Contacted__C": "Rupesh",
"Inspected__C": "",
"Lost__C": "Fire",
"Job Start Date__C": "2019-10-25",
"Work Complete__C": "",
"Billing Complete__C": ""
}
}]
Using the DW script mentioned below:-
%dw 2.0
output application/xml
---
{
XACTDOC: {
XACTNET_INFO: {
CONTROL_POINTS: {
(payload map ( payload01 , indexOfPayload01 ) -> {
CONTROL_POINT @("type": if(payload01.Master_Job__r."Customer Contacted__C" != "") payload01.Master_Job__r."Customer Contacted__C" else null,
"type": if (!isEmpty(payload01.Master_Job__r."Inspected__C")) "" else payload01.Master_Job__r."Inspected__C",
"type": payload01.Master_Job__r.Lost__C ,
"type": payload01.Master_Job__r."Job Start Date__C" ,
"type": payload01.Master_Job__r."Work Complete__C" ,
"type": payload01.Master_Job__r."Billing Complete__C"
): {
}
})
}
}
}
}
When Transforming the data below is the result
<?xml version='1.0' encoding='UTF-8'?>
<XACTDOC>
<XACTNET_INFO>
<CONTROL_POINTS>
<CONTROL_POINT type="Rupesh" type="" type="Fire" type="2019-10-25" type="" type=""/>
</CONTROL_POINTS>
</XACTNET_INFO>
</XACTDOC>
The second input json value is empty then in output i dont want to display anything but in my output it is displaying as type="" . If the value is present then i need to display.The value is generated dynamically.