Help with payload script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2025 07:16 PM
Hi,
Can someone please help or gudie me in the right direction.
I'm kinda of stuck with payload for remote spoke ebonding. Destination has sub state "On hold Reason" and my source has no "On hold reason" (i am the source)
Below is the mapping I'm trying to map
Source to Destination |
New > New |
Active > In Progress |
Awaiting Problem > On Hold - awaiting problem |
Awaiting User Info > On Hold - awaiting user |
Awaiting Evidence > On Hold - awaiting user |
Resolved > Resolved |
Closed > Closed |
correlation_display: this.correlation_display,
short_description: incidentRec.getDisplayValue('short_description'),
state: incidentRec.getDisplayValue('state'),
state: incidentRec.getValue('state'),
state: this.stateMappingOut(incidentRec.getValue('state')),
//hold_reason: incidentRec.getDisplayValue('hold_reason'),
caller_id: incidentRec.getDisplayValue('caller_id'),
business_service: incidentRec.getDisplayValue('business_service'),
category: incidentRec.getDisplayValue('category'),
subcategory: incidentRec.getDisplayValue('subcategory'),
impact: incidentRec.getValue('impact'),
urgency: incidentRec.getValue('urgency'),
u_external_incident_number: incidentRec.getValue('u_external_incident_number'),
assignment_group: incidentRec.getValue('prime: assignment_group'),
// close_code: incidentRec.getValue('close_code'),
close_notes: incidentRec.getValue('close_notes'),
};
if (incidentRec.state == '6') {
if (incidentRec.close_code == "Resolved by Vendor") {
incidentValues.close_code = "Solved By Vendor";
} else {
incidentValues.close_code = "Solved Remotely (Permanently)";
}
}
return incidentValues;
},
buildDesc: function(incidentRec) {
var desc = "Caller: " + incidentRec.getDisplayValue('caller_id');
desc += "\nLocation: " + incidentRec.getDisplayValue('location');
desc += "\nCI: " + incidentRec.getDisplayValue('cmdb_ci');
desc += "\nCategory: " + incidentRec.getDisplayValue('category');
desc += "\nSubcategory: " + incidentRec.getDisplayValue('subcategory');
desc += "\n\n" + incidentRec.getDisplayValue('description');
return desc;
},
stateMappingOut: function(state, substate) {
if (state == 3 && !substate.nil()) { //awaiting problem
if (state == 4) { //Awaiting User
return "4"; //Awaiting User Info
} else if (substate == 3) { //Awaiting Problem
return "3"; //Awaiting Problem
} else {
return "5"; //Awaiting Evidence
}
} else {
return state;
}
},
escalateIncidentPayload: function(incident_sys_id) {
var incidentSysId = incident_sys_id;
var incidentRec = new GlideRecord('incident');
incidentRec.get(incidentSysId);
var incidentValues = {
assignment_group: "Support 1",
};
return incidentValues;
},
createRequestPayload: function(task_sys_id) {
var taskSysId = task_sys_id;
var taskRec = new GlideRecord('sc_task');
taskRec.get(taskSysId);
var taskValues = {
state: taskRec.getDisplayValue('state'),
u_resolution: taskRec.getDisplayValue('close_notes')
};
return taskValues;
},
createWorknote: function(task_sys_id) {
var taskSysId = task_sys_id;
var taskRec = new GlideRecord('task');
taskRec.get(taskSysId);
var taskValues = {
work_notes: taskRec.work_notes.getJournalEntry(1),
};
return taskValues;
},
createComments: function(task_sys_id) {
var taskSysId = task_sys_id;
var taskRec = new GlideRecord('task');
taskRec.get(taskSysId);
var taskValues = {
comments: taskRec.comments.getJournalEntry(1),
};
return taskValues;
},
type: 'SSNPayloadbuilder'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2025 09:00 PM
@Thomas98 - Please add one more function to get the on hold reason from the state values as given below
getHoldReasonSubstateMappingOut: function(state) {
if (state == 3) { //awaiting problem
return "3";
} else
return "1"; //Awaiting User Info
}
and update the line in your payload
to
hold_reason : [3,4,5].includes(state) ? this.getHoldReasonSubstateMappingOut(incidentRec.getValue('state'))) : "",
then do test
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2025 07:32 PM
@Thomas98 - OOTB you have the on-hold reason field. Please refer the screenshot below
Please check and share if you still need any further support
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2025 07:39 PM
Ours is older instance. We do not have on hold reason as a state and no sub status.