Scheduled job script that fill out data in catalog item form couldn't pass value to display in task short description

bbf3562
Kilo Guru

When I fill out information in catalog item form and then submit, it was able to pass values from catalog item variable to task fields to display value in Short Description and Description like this,

find_real_file.png

 

But when I use scheduled job script that execute it by filling information itself in catalog item, it show that it success filling data in catalog item in task requested item variables ticket but it couldn't pass value to display in Short Description and Description that cause blank,

find_real_file.png

 

Does anyone know why it show blanks in task description if execute scheduled job script but it show data in task description if I manually fill the data in catalog form?

1 ACCEPTED SOLUTION

Setting the variables from the scheduled job in that manner is going to happen on the Requested Item and not the task table, which is why the Task Short Description and Description are not populating.  You need to set the Task Short Description and Description in the workflow itself and you can reference Requested Item variables to do so.  

For example:

task.description = current.variables.group_name (if this is a reference filed add .getDisplayValue() on the end)


Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

View solution in original post

6 REPLIES 6

Steven Parker
Giga Sage

Are you using this type of logic to populate your catalog item and submit it from a Scheduled Job?

var cart = new Cart();

//pass Catalog Item sys_id
var item = cart.addItem('9efcc297dbef7a0002e4fb761d9619f0');

//Set the Variables for Review

cart.setVariable(item, 'Service_type', 'annual_review');
cart.setVariable(item, 'requester', requester1);
cart.setVariable(item, 'existing_vendor', vendor);
		

//Submit Request
var rc = cart.placeOrder();

Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

Yes I did. I use,

var cart = new Cart();
				var item = cart.addItem("8d72ac634fee9a005a152cee0210c759"); // ServiceNow Maintenance Request
				//cart.setVariable(item, "src_requested_for", owner.manager);
				cart.setVariable(item, "short_description", owner.manager.getDisplayValue());				
				cart.setVariable(item, "description", owner.name);
				
				cart.placeOrder();

It was successful able to input in catalog item variables but couldn't pass values to task short description/description after submitted even though it does show it success entered under Requested Item Variables tab.

find_real_file.png

 In task workflow script, I put,

var shortDesc = current.variable_pool.src_short_desc;
var longDesc = current.variable_pool.src_long_desc;


task.short_description = shortDesc;
task.description = longDesc;

Harsh Vardhan
Giga Patron

what exactly have you written in your scheduled job?

i believe you did glide record to fetch the catalog variables value and on RITM level then updated into the task ?

or have you used cart API?

I use glide record to pull group names from sys_user_group

Then I use,

var cart = new Cart();
				var item = cart.addItem("8d72ac634fee9a005a152cee0210c759"); // ServiceNow Maintenance Request
				//cart.setVariable(item, "src_requested_for", owner.manager);
				cart.setVariable(item, "short_description", owner.manager.getDisplayValue());				
				cart.setVariable(item, "description", owner.name);
				
				cart.placeOrder();

It was successfully entered data in catalog item variables because it show in task Requested Item Variables tab but not able to pass value to task short description and description,

find_real_file.png

In task workflow, I did put

var shortDesc = current.variable_pool.src_short_desc;
var longDesc = current.variable_pool.src_long_desc;


task.short_description = shortDesc;
task.description = longDesc;