Create change using the entered values in catalog form/ritm
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2022 12:50 AM
We have a requirement in which user will enter values in catalog form, then RITM will be created and after that change is created, and when the change is closed, the ritm will be closed automatically. Please let me know how we can implement this requirement in servicenow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2022 01:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2022 01:42 AM
Hello @AKASH BANERJEE ,
Gunjan has replied to your script you can go by that approach too. If you require a solution by my approach let me know I will develop it and attach the screenshots for you.
BR,
Nayan
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2022 01:32 AM
Hi @AKASH BANERJEE ,
You can create BR on request item table as below
On After Insert
Condition : Item is 'your catalog item name'
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var gr = new GlideRecord("change_request");
gr.initialize();
gr. u_requested_item=current.sys_id; //Establish connection between them using this
gr.short_description=current.variables.variableName;
gr.cmdb_ci=current.variables.variableName;
//mapp all your catalog variables like this // Repalce "variableName" with variable backend name
gr.insert()
})(current, previous);
Create new field as requested item on change form :-
Write down BR on Change request table :-
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var gr = new GlideRecord("sc_req_item");
gr.addQuery("sys_id", current.u_requested_item);
gr.query();
if (gr.next()) {
gr.state = '3';
gr.stage = 'complete';
gr.update();
}
})(current, previous);
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2022 07:13 AM
I have figured out the below script in workflow, which is taking values from workflow but the issue is workflow is running fine but it is not creating a normal change. Please let me know what is the issue behind it.
var chg = new GlideRecord('change_request');
chg.initialize();
chg.type = 'normal'; //static values
chg.u_change_template = 'example 1'; //static values
chg.assignment_group = 'Group xyz';//static values
chg.requested_by = current.variables.requested_by;
chg.category = current.variables.category;
chg.u_business_application = current.variables.business_application;
chg.cmdb_ci = current.variables.configuration_item;
chg.risk = current.variables.risk;
chg.u_technical_approval_groups = current.variables.change_management_group;
chg.short_description = current.variables.short_description;
chg.description = current.variables.description;
chg.justification = current.variables.justification;
chg.implementation_plan = current.variables.implementation_plan;
chg.risk_impact_analysis = current.variables.risk_and_impact_analysis;
chg.backout_plan = current.variables.backout_plan;
chg.test_plan = current.variables.test_plan;
chg.start_date = current.variables.planned_start_date;
chg.end_date = current.variables.planned_end_date;
chg.insert();