- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2024 01:59 PM
Im trying to set my category field on the incident form based on a variable collected from the record producer. the following is what i currently have, but it is only setting to the default.
var isMobile = GlideMobileExtensions.getDeviceType() == 'm';
var link = isMobile ? '#/!list/incident/q:active=true%5Ecaller_id=javascript:gs.user_id()%5EEQ' : 'home.do';
var linkLbl = isMobile ? "List" : "Homepage";
var br = '<br/>';
var linkURL = '<a href="' + link + '">' + gs.getMessage(linkLbl) + '</a>';
var msgArgs = [br, linkURL];
var callerSysID = gs.getUserID();
var parent_table = RP.getParameterValue('sysparm_parent_table');
if (JSUtil.notNil(parent_table)) {
var parent_map = new GlideRecord('request_parent_mapping');
parent_map.addQuery('parent_table', parent_table);
parent_map.query();
if (parent_map.next())
var requested_for_field = parent_map.getValue('requested_for_field');
var parentGR = new GlideRecord(parent_table);
parentGR.addQuery('sys_id', RP.getParameterValue('sysparm_parent_sys_id'));
parentGR.query();
if (parentGR.next())
callerSysID = parentGR.getValue(requested_for_field);
}
var callerGR = new GlideRecord('sys_user');
callerGR.get(callerSysID);
var callerDV = callerGR.getDisplayValue();
//set service and service offering
current.contact_type = 'self-service';
current.caller_id = callerSysID;
current.business_service='377d075ec3c40610618d1fb4e4013126'; //377d075ec3c40610618d1fb4e4013126 = 'ATM/ITM' service
current.service_offering = '445ecb5ec3c40610618d1fb4e40131eb'; // 445ecb5ec3c40610618d1fb4e40131eb = 'ATM/ITM' offering
//Set Description
var descriptionStr = producer.cmdb_ci.name;
descriptionStr += " at location " + producer.cmdb_ci.location.name;
descriptionStr += " has and issue of " + producer.issue_descriptions;
current.short_description = descriptionStr;
//Set Assignment Group
current.assignment_group = "9ac98878c326b150618d1fb4e4013134"; //9ac98878c326b150618d1fb4e4013134 = Cash Delivery Systems
// Set Category (server-side)
var selectedIssue = producer.issue_descriptions;
switch (selectedIssue) {
case 'ATM Side':
case 'Audio':
case 'Audio/Video':
case 'Black Screen':
case 'Frozen Session':
case 'Lost Comms':
case 'Offline':
case 'Session Closed Unexpectedly':
case 'Session Froze':
// Set the Category field value to 'connectivity'
current.category = 'connectivity';
break;
case 'Project - Professional Services':
// Set the Category field value to 'database'
current.category = 'database';
break;
default:
// Optionally, set a default category or handle other cases
current.category = 'Communication'; // or any default value
break;
}
var incRPUtil = new LinkRecordProducerToIncident();
incRPUtil.linkRecordProducerToParentIncident(RP.getParameterValue('sysparm_parent_sys_id'), current);
also her is a screen shot of the choices for the issue_descriptions variable
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2024 02:25 PM
Can you add toString() and see if it works?
var selectedIssue = producer.issue_descriptions.toString();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2024 02:06 PM
The first thing I would do is log selectedIssue before the switch to confirm its value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2024 02:25 PM
Can you add toString() and see if it works?
var selectedIssue = producer.issue_descriptions.toString();