Click here to Skip to main content
15,886,611 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.
Posted
Updated 16-Nov-17 20:57pm
Comments
Patrice T 17-Nov-17 3:08am    
'But it throws me an error'
Which error message ?
Graeme_Grant 17-Nov-17 4:07am    
You should fix the formatting and add the JSON tag...
Sinisa Hajnal 17-Nov-17 11:12am    
What is the error? Can't you find and correct the cause based on that?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900