Input JSON
{
"assignment_group": "Test",
"category": "software",
"comments": "Test",
"configuration_item": "Test",
"description": "TEST",
"file": {
},
"impact": "3",
"number": "INCxxxxxx",
"short_description": "TESt",
"state": "Active",
"subcategory": "windows",
"urgency": "4"
}
Transformer
{
"action":"update" ,
"type":"incident",
"correlation_id": "#valueof($.number)",
"payload":{
"short_description": "#valueof($.short_description)",
"description": "#valueof($.description)",
"state": "#ifcondition(#valueof($.state),New,1,
#ifcondition(#valueof($.state),Resolved,6,
#ifcondition(#valueof($.state),Work In Progress,9,
#ifcondition(#valueof($.state),Awaiting User Info,10,
#ifcondition(#valueof($.state),Cancelled,6,
#ifcondition(#valueof($.state),Other,#valueof($.state),''))))))",
"impact": "#ifcondition(#valueof($.impact),1,1,
#ifcondition(#valueof($.impact),2,1,
#ifcondition(#valueof($.impact),3,2,
#ifcondition(#valueof($.impact),4,3,true))))",
"urgency": "#ifcondition(#valueof($.urgency),1,1,
#ifcondition(#valueof($.urgency),2,1,
#ifcondition(#valueof($.urgency),3,2,
#ifcondition(#valueof($.urgency),4,3,true))))",
'assignment_group':'#ifcondition(#valueof($.assignment_group),Test,True,
#ifcondition(#valueof($.assignment_group),Other,Test2,False))' ,
"cmdb_ci": "#valueof($.configuration_item)",
//"close_code": "#valueof($.close_code)",
"close_notes": "#valueof($.close_notes)",
"comments": "#valueof($.comments)",
"attachment":{
"file_name": "#valueof($.attachment.file_name)",
"content": "#valueof($.attachment.content)",
"content_type": "#valueof($.attachment.content_type)"
}
}
}
What I have tried:
Scenario-1
In my input there is no close code,but in Transforamtion there is value of close code which is being sent as Null.I want to delete the same if not existing.
I tried couple of methods.
//"close_code":"#ifcondition(#exists($.close_code),true,#delete($.close_code))" ,
//"close_code": ["#valueof($.close_code)","#delete($.close_code)"],
But it throws me an error
2)Second scenario is that if(if)-condition is not satsified then also that node be deleted.