- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2021 04:26 AM
Scenario: There is variable "XYZ" in a catalog item which is "Reference" type and table is "Task".
Other variable is "Requested for" which is "Reference" type and table is "sys_user".
And Last variable is "Description" which is "multiline text" type.
Expected sol 1: If the user selects 'Incident' from "XYZ" variable then the "Requested for" and "Description" input should be copied to selected Incident's work notes.
Expected sol 2: If the user selects 'RITM' from "XYZ" variable then the "Requested for" and "Description" input should be copied to selected RITM ticket's work notes if that RITM does not contain SCTASK. If the RITM contain SCTASK then data should be copied to that RITM's SCTASK work notes.
Note: Here I am using workflow for this catalog item.
Is there any way to achieve this solution??????????
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2021 05:40 AM
Hi Vishal,
I would recommend you use a Workflow Script on the catalog item that will amend the task e.g.:
Scenario 1:
var task = new GlideRecord("task");
task.get('sys_id', current.variables.task_variable);
task.work_notes = "Requested for: " + current.variables.requested_for_variable + "\n + "\n" + "Description: " + current.variables.description_variable;
task.update();
Scenario 2:
var reqitem = new GlideRecord("sc_req_item");
reqitem.addQuery('sys_id','current.variables.task_variable');
reqitem.query();
if (reqitem.next()){
reqitem.work_notes = "Requested for: " + current.variables.requested_for_variable + "\n + "\n" + "Description: " + current.variables.description_variable;
reqitem.update();
var reqtask = new GlideRecord("sc_task"):
reqtask.addQuery('request_item', reqitem.sys_id);
reqtask.query();
while (reqtask.next()){
reqtask.work_notes = "Requested for: " + current.variables.requested_for_variable + "\n + "\n" + "Description: " + current.variables.description_variable;
reqtask.update();
}
}
You can add criteria in your catalog items to restrict task types so that each workflow runs the correct script or create an if statement on your workflow to direct the workflow depending on class type of selected task.
Let me know if this helps and mark this as helpful/solved.
Thanks,
Enrique

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2021 07:28 AM
No problem
Let me know if you need any further help!