- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2020 01:37 AM
Hi,
i am not sure why this error in coming and how can we remove it. is there any other way to call if condition please let me what have i done wrong. PFB screenshot for reference.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2020 02:45 AM
Hi,
try adding logs
if (gr.next()) {
var obj = {};
obj["Number"] = gr.number + '';
obj["State"] = gr.state.getDisplayValue();
gs.info('state'+gr.state.getDisplayValue());
if (gr.state.getDisplayValue() == 'In progress') {
obj["Sub state"] = gr.hold_reason.getDisplayValue();
}
inc.push(obj);
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2020 01:46 AM
Hi,
please format your script
Also share complete script here
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2020 01:49 AM
Hi Ankur,
PFB complete script
var getIncidentDetails = Class.create();
getIncidentDetails.prototype = {
initialize: function() {},
getDetails: function(number) {
var inc = [];
var gr = new GlideRecord('incident');
gr.addQuery('number', number);
gr.query();
if (gr.next()) {
inc.push({
'Number': gr.number + '',
'State': gr.getDisplayValue('state') + '',
if (gr.getDisplayValue('state') == 'In progress') {
'Sub state': gr.getDisplayValue('hold_reason')
}
//'Short Description': gr.short_description
});
return inc;
}
}
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2020 01:56 AM
Hi,
updated script
var getIncidentDetails = Class.create();
getIncidentDetails.prototype = {
initialize: function() {
},
getDetails: function(number) {
var inc = [];
var gr = new GlideRecord('incident');
gr.addQuery('number', number);
gr.query();
if (gr.next()) {
var obj = {};
obj["Number"] = gr.number + '';
obj["State"] = gr.state.getDisplayValue();
if (gr.state.getDisplayValue() == 'In progress') {
obj["Sub state"] = gr.hold_reason.getDisplayValue();
}
inc.push(obj);
}
return inc;
},
type: 'getIncidentDetails'
};
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2020 02:04 AM
Hi Ankur,
this is not working. it is not showing sub state in any case