
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2020 07:34 AM
I've created a UI Script to be able to create a Change Request from a RITM.
This works fine - but is there a way to copy all variables from a RITM and create them on a Change Request?
Depending on Catalog Item, the variables may change/have different name/purpose so I don't want to hard code any variables. Is there a way for this?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2020 06:55 AM
Here's the script I made to do what I was looking for.
//copy variables from ritm to change request form
var ritmVar = new GlideRecord('sc_item_option_mtom');
ritmVar.addQuery('request_item', current.getUniqueValue());
ritmVar.addNotNullQuery('sc_item_option.value');
ritmVar.orderBy('sc_item_option.order');
ritmVar.query();
while(ritmVar.next()) {
var chgVar = new GlideRecord('question_answer');
chgVar.initialize();
chgVar.table_name = 'change_request';
chgVar.table_sys_id = chgSysId;
chgVar.question = ritmVar.sc_item_option.item_option_new;
chgVar.order = ritmVar.sc_item_option.order;
chgVar.value = ritmVar.sc_item_option.value;
chgVar.insert();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2020 12:54 PM
Hmm.. I don't think I understand... This is for creating automatic CHG from a workflow not nothing about getting the variables from one table to another.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2020 06:55 AM
Here's the script I made to do what I was looking for.
//copy variables from ritm to change request form
var ritmVar = new GlideRecord('sc_item_option_mtom');
ritmVar.addQuery('request_item', current.getUniqueValue());
ritmVar.addNotNullQuery('sc_item_option.value');
ritmVar.orderBy('sc_item_option.order');
ritmVar.query();
while(ritmVar.next()) {
var chgVar = new GlideRecord('question_answer');
chgVar.initialize();
chgVar.table_name = 'change_request';
chgVar.table_sys_id = chgSysId;
chgVar.question = ritmVar.sc_item_option.item_option_new;
chgVar.order = ritmVar.sc_item_option.order;
chgVar.value = ritmVar.sc_item_option.value;
chgVar.insert();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2021 02:44 PM
Hey Henrik,
Did you put this in the UI action?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2021 03:03 AM
No I think it was a Business Rule actually.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2021 01:32 PM
Thanks for the reply back. I think I need a UI Action to create change but only on a specific request item. So I can hard code it if needed. Not sure if that is possible.