Unable to fetch values from variables of a catalog task into a RITM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 08:50 PM
Hello Team,
I am able to relate a new RITM in an existing request through a UI action. However I am unable to get the values like assignment group; & short description to be populated into the RITM. What may be the reason The code is as follows, the entire process is working through a UI action (involving insert of variable data etc.). can someone advise asap?
//Creating the RITM
var reqHelper = new GlideappCalculationHelper();
reqHelper.addItemToExistingRequest(current.request, '0728b2051ba60014334efc031d4bcb61', 1); // 1 is the qty
reqHelper.rebalanceRequest(current.request);
// Update the variables in the created RITM
var createRITM = new GlideRecord("sc_req_item");
createRITM.initialize();
createRITM.assignment_group = current.assignment_group;
createRITM.short_description = "Discovery on demand – " + current.variables.ip_address;
Regards
Nilanjan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 08:53 PM
By the initialize function, I'm seeing you're creating a new RITM. However, I'm unable to understand the use case. Where is this function running? Is this a Before Business Rule? What are the other functions, do we need to be seeing them in-depth?
I'm still unable to understand where the Catalog Task comes in place. Is this a BR on that table?
Need more context.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 09:34 PM - edited 01-12-2023 09:36 PM
Hello Aditya,
Thank you for getting back to me.. here is the complete script. To give you a back ground. We are trying to create a RITM & attaching it to the request from a UI action and this UI action is also used to update the CMDB data in respective tables. So this UI action once clicked would create an entry with the variable details in the respective CMDB table and at the same time would create a RITM attaching itself to the request (Original Request). In the meanwhile it would populate the information such as assignment group and the short description in the process.
var APCServerUtil = Class.create();
APCServerUtil.prototype = {
initialize: function() {},
createServer: function(current) {
var serverTableName = current.variables.sys_class_name;
var grServer = new GlideRecord(serverTableName);
grServer.initialize();
grServer.name = current.variables.name;
grServer.location = current.variables.location;
grServer.operational_status = current.variables.operational_status;
grServer.install_status = current.variables.status; // Change the backend value from status to install_status
grServer.sys_class_name = current.variables.sys_class_name;
grServer.u_billable_2 = current.variables.billable;
grServer.u_device_type = current.variables.billable_device_type;
grServer.install_date = current.variables.installed_date; // Change the backend value from installed_date to install_date
grServer.u_vendor_managed_1 = current.variables.vendor_managed;
grServer.vendor = current.variables.vendor;
grServer.ip_address = current.variables.ip_address;
grServer.u_reboot_notes = current.variables.reboot_notes;
grServer.maintenance_schedule = current.variables.maintenance_schedule;
grServer.used_for = current.variables.used_for;
grServer.os = current.variables.operating_system;
grServer.environment = current.variables.environment;
grServer.dns_domain = current.variables.dns_domain;
grServer.virtual = current.variables.is_virtual;
grServer.short_description = current.variables.description;
grServer.insert();
var reqHelper = new GlideappCalculationHelper();
reqHelper.addItemToExistingRequest(current.request, '0728b2051ba60014334efc031d4bcb61', 1); // 1 is the qty
reqHelper.rebalanceRequest(current.request);
var createRITM = new GlideRecord("sc_req_item");
//createRITM.initialize();
//createRITM.addItemToExistingRequest(current.request, '0728b2051ba60014334efc031d4bcb61', 1); // 1 is the qty
//createRITM.request = current.request;
//createRITM.cat_item = current.sys_id;
//createRITM.u_requested_for = current.u_requested_for;
createRITM.assignment_group = current.assignment_group;
createRITM.short_description = "Discovery on demand – " + current.variables.ip_address;
//createRITM.rebalanceRequest(current.request);
//createRITM.insert();
},
type: 'APCServerUtil'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2023 10:00 AM
Hello Aditya,
Can you help ?
regards
Nilanjan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2023 10:11 AM
Based on the script you've provided, it looks like you're creating a new server record in the CMDB by initializing a new GlideRecord for the table specified in the serverTableName variable and then setting the various fields on the record using the values from the current.variables object.
Then you are creating a RITM by creating a new GlideRecord for the "sc_req_item" table and then setting the "assignment_group" and "short_description" fields on the RITM record using the values from the current.assignment_group and the concatenation of the "Discovery on demand – " string and the current.variables.ip_address variable.
It seems that there are some commented lines in the script, which are not needed and causing confusion. I would recommend removing those commented lines and also making sure that the fields you are trying to set in RITM table have the same names in both RITM table and current object.
Also, it looks like you are trying to call the addItemToExistingRequest method on both GlideappCalculationHelper and GlideRecord object, but it doesn't seem to be defined on GlideRecord. Also, you are trying to call the rebalanceRequest method on GlideappCalculationHelper object, but that is also not defined.