- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2024 02:17 PM
Good day everyone,
I currently am using a UI Action to convert a RITM to a CHG. Within this UI Action, I have a few data fields that get copied over to the CHG ticket, of those variables is the Watch List.
Below is a sample of my current script that I am currently copying over fields from RITM > CHG and a few of them are just OOTB. I've tried to copy over the "watch_list" field that is on the RITM to no avail. The one highlighted in blue, I tried creating a variable on the form that gathers the watch list and tried to copy that to the CHG (similar to others). I know I am missing something and would like your second/third set of eyes to understand where I am going wrong.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2024 06:52 PM
Hi @Joel O,
I am not sure if you are talking about the watch_list field on the RITM. If so, the code should be the following:
changeRequest.setValue("watch_list", current.getValue('watch_list'));
If you are using a variable, can you share its configuration as well?
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2024 02:57 PM
@Joel O Try the below script.
var changeRequest = new ChangeRequest();
changeRequest.setValue("short_description", current.variables.short_description);
changeRequest.setValue("cmdb_ci", current.variables.cmdb_ci);
changeRequest.setValue("u_client", current.variables.client);
changeRequest.setValue("u_environment", current.variables.environment);
if (changeRequest.hasValidChoice('priority', current.priority))
changeRequest.setValue("priority", current.priority);
changeRequest.setValue("sys_domain", current.sys_domain);
changeRequest.setValue("company", current.company);
changeRequest.setValue("risk_impact_analysis", current.variables.risk_and_impact_analysis);
changeRequest.setValue("justification", current.variables.justification);
changeRequest.setValue("start_date", current.variables.planned_start_date_ci);
changeRequest.setValue("requested_by", current.request.requested_for);
changeRequest.setValue("parent", current.sys_id);
// Copy the watch list from RITM to CHG
var watchList = new GlideList();
watchList.setTableName("sys_user");
watchList.addQuery("user_name", "IN", current.variables.watch_list.toString());
watchList.query();
var watchListSysIDs = [];
while (watchList.next()) {
watchListSysIDs.push(watchList.getValue("sys_id"));
}
changeRequest.setValue("watch_list", watchListSysIDs);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 06:56 AM
Thanks @VarunS I'll test this out but appreciate your reply.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2024 06:52 PM
Hi @Joel O,
I am not sure if you are talking about the watch_list field on the RITM. If so, the code should be the following:
changeRequest.setValue("watch_list", current.getValue('watch_list'));
If you are using a variable, can you share its configuration as well?
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 06:55 AM
Thanks @James Chun this is what I was looking to accomplish with using the existing field on the RITM. I tried to go down the route of using variables but this is simpler and easy to add.