
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2016 03:11 PM
We have a custom provisioning process that creates a request from an email, and two items (fulfillment and billing) within that request. Each item has 'standard' tasks that are created via the workflow. The provisioning team then has to create a bunch of new tasks within the item to complete the provisioning of services.
I have a variable, req_details, that is visible on the items, and is visible on the auto-created catalog tasks. But when we create a new task within the item, the variable is not visible. The Variable Editor is on the form (obviously, because we can see it on the other tasks...)
I'm at a loss as to why that field doesn't show on the manually created tasks. Any ideas?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2016 04:14 PM
Hi kchorny
Write a before insert business rule on sc_task table and put this script in there.
(function executeRule(current, previous /*null when async*/) {
var vars = new GlideRecord("item_option_new");
vars.addQuery('cat_item', current.request_item.cat_item);
vars.query();
while (vars.next()) {
insertVariable(vars.sys_id);
}
function insertVariable(id) {
var gr = new GlideRecord('sc_item_variables_task');
gr.initialize();
gr.setValue('task', current.getValue('sys_id'));
gr.setValue('variable', id);
gr.insert();
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2016 03:20 PM
One reason I could think of is, when the tasks are created form the workflow, you do add the variables on to the form in the create task activity.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2016 03:23 PM
Correct. So how do I get it to show up on tasks NOT created through the workflow?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2016 04:14 PM
Hi kchorny
Write a before insert business rule on sc_task table and put this script in there.
(function executeRule(current, previous /*null when async*/) {
var vars = new GlideRecord("item_option_new");
vars.addQuery('cat_item', current.request_item.cat_item);
vars.query();
while (vars.next()) {
insertVariable(vars.sys_id);
}
function insertVariable(id) {
var gr = new GlideRecord('sc_item_variables_task');
gr.initialize();
gr.setValue('task', current.getValue('sys_id'));
gr.setValue('variable', id);
gr.insert();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2017 05:26 AM
The above scrip works great on variables that are not in a variable set. When I look at the table I dont see variable set variables included there. Is there a way to include variable sets also?