- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2014 03:42 PM
We are creating sctasks, in a workflow that is not driven by a Service Catalog Item, for our Support Desk. The workflow is not tied to the Tasks table. Is it possible to use a Run Script activity to dynamically create a Request and an associated RITM, then use a Catalog Task to create the sctask and associate that to the RITM? We want to create this tree so that we retain the ability to dot-walk fields.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2014 03:56 AM
Hi Chadlockwood,
I got the reason why it was giving you "NullPointerException". It was because of the line "task.requested_for = "SET THE USER VALUE HERE";" and "task.request_item.requested_for = "SET THE USER VALUE HERE";" as there is no requested for field on either of task and requested item table. requested item field shown on these forms are coming from request table if you check and personalize the form layout. I hope I am making sense here.
Below is the tried and tested code which you can use.
var task = new GlideRecord('sc_task');
task.initialize();
task.short_description = "ENTER THE SHORT DESCRIPTION HERE";
task.request_item.short_description = "ENTER THE SHORT DESCRIPTION FOR REQUESTED ITEM HERE";
task.request_item.request.short_description = "ENTER THE SHORT DESCRIPTION FOR REQUEST HERE";
task.request_item.request.requested_for = gs.getUserID();
task.insertWithReferences();
Please mark answered if it really resolve your issue.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2014 03:56 AM
Hi Chadlockwood,
I got the reason why it was giving you "NullPointerException". It was because of the line "task.requested_for = "SET THE USER VALUE HERE";" and "task.request_item.requested_for = "SET THE USER VALUE HERE";" as there is no requested for field on either of task and requested item table. requested item field shown on these forms are coming from request table if you check and personalize the form layout. I hope I am making sense here.
Below is the tried and tested code which you can use.
var task = new GlideRecord('sc_task');
task.initialize();
task.short_description = "ENTER THE SHORT DESCRIPTION HERE";
task.request_item.short_description = "ENTER THE SHORT DESCRIPTION FOR REQUESTED ITEM HERE";
task.request_item.request.short_description = "ENTER THE SHORT DESCRIPTION FOR REQUEST HERE";
task.request_item.request.requested_for = gs.getUserID();
task.insertWithReferences();
Please mark answered if it really resolve your issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2014 09:00 AM
That did it! I do now see what you were saying previously about how these SCTASKs will not change the state of the RITM/REQ, however, I'm pretty sure we can deal with that with a business rule. I also added:
workflow.scratchpad.ritmid = task.request_item.sys_id;
so that I could associate subsequent SCTASKs in the WF by adding:
task.request_item = workflow.scratchpad.ritmid;
Thank you for your help