Where are the variables stored on catalog task?

mrswann
Kilo Guru

I have a great script sourced from a range of posts here, which is working very nicely to pull through ALL the variables for the Requested Item

template.print("<b><u>Summary of Requested items:</u></b><br/>");

var item = new GlideRecord("sc_req_item");

item.addQuery("sys_id", current.request_item); //item.addQuery("sys_id", current.sysapproval); //for catalog approval

item.query();

while(item.next()) {

template.print(item.number + ": " + item.quantity + " X " + item.cat_item.getDisplayValue() + "<br/>");

template.print("<br/>Options: <br/>");

var keys = new Array();

var set = new GlideappVariablePoolQuestionSet();

set.setRequestID(item.sys_id);

set.load();

var vs = set.getFlatQuestions();

for (var i=0; i < vs.size(); i++) {

if (vs.getLabel() != "" && vs.getDisplayValue() != "" && vs.getDisplayValue()!='false') {

//template.space(3);

template.print("<br/> <b>" + vs.get(i).getLabel() + "</b> = " + vs.get(i).getDisplayValue() + "");

}

}

}

However, my workflow is only pulling through the respective variables to each task so that the teams are not flooded with irrelevant information.

The challenge today is these teams are not on board in the tool and wont be fulfilling the tasks online. They will be receiving an email as a result of the task assignment to their group mailbox.

Once complete they will respond back. This is a stepping stone to automate an otherwise convoluted procedure.

Thus I would like to ONLY pull through the variables into the Email Notification which belong to the Task and not the Requested Item!?

The script above is a Notification Email Script and works very well at the point of group assignment for the task. Any clues how I can restrict the content to variables attached to the task?

1 ACCEPTED SOLUTION

mrswann
Kilo Guru

after


set.setRequestID(SYSID OF REQUESTED ITEM);


I also added:


set.setTaskID(SYSID OF REQUESTED ITEM TASK);



this is now limiting the values specific to the task!




template.print("<b><u>Summary of Requested items:</u></b><br/>");


var item = new GlideRecord("sc_req_item");


item.addQuery("sys_id", current.request_item);


item.query();


while(item.next()) {


template.print(item.number + ": " + item.quantity + " X " + item.cat_item.getDisplayValue() + "<br/>");


template.print("<br/>Options: <br/>");


var keys = new Array();


var set = new GlideappVariablePoolQuestionSet();


set.setRequestID(item.sys_id);


set.setTaskID(current.sys_id);


set.load();


var vs = set.getFlatQuestions();


for (var i=0; i < vs.size(); i++) {


//if (vs.getLabel() != "" && vs.getDisplayValue() != "" && vs.getDisplayValue()!='false' && vs.visible == true) {


if (vs.getLabel() != "" && vs.getDisplayValue() != "" && vs.getDisplayValue()!='false'   &&   vs.get(i).getDisplayValue()!= 'false' &&   vs.get(i).getDisplayValue()!= '') {


//template.space(3);


template.print("<br/> <b>" + vs.get(i).getLabel() + "</b> = " + vs.get(i).getDisplayValue() + "");


}


}


}


View solution in original post

9 REPLIES 9

poyntzj
Kilo Sage

In your workflow, when you launch the catalog task make sure that only the variables you need are selected


then in that above script, should be a case of changing line 2 to be the relevant catalog task table


larstange
Mega Sage

To see which variables are selected for the particular task, you will need to look in the workflow activity definition (wf_activity). Here the setup of the task in the specific workflow is saved.


find_real_file.png


The selected values of the slush bucket is saved in sys_variable_value



You will need to search for ID = sys_id of wf_activity record and find the entry with order = 1700


find_real_file.png


mrswann
Kilo Guru

OK thanks both - I do know what variables are assigned to each task as I have set them as per these steps!


They are showing very nicely on the catalog task records.



I am not totally clear where they are stored in the system.



To Julian's point: " changing line 2 to be the relevant catalog task table"



What is the relevant catalog task table? How/where are these defined?



This is probably quite simple, so apologies! I have seen a few questions in the community about this with no explicit answer?



larstange
Mega Sage

The variables on the task are identical to the variables on the requested item - they contain the same value.


So you need to first find which variables have been selected for the specific task, and then get the value in only these variables from script that you found.