Displaying catalog variables on catalog task created by run script

PJ1
Tera Contributor

Hi, I have a requirement to create multple catalog task dimanically in workflow. I achived that by a run script using glide record. however Catalog variables are not showingup on the   tasks created. Did any one try showing catalog variables on tasks created by a script.

16 REPLIES 16

donnie5
Mega Expert

Hi, Prajwa:



You should be able to access the catalog variables in your workflow script by using current.variables.VariableName.



In our case, we're using a Task Activity to create catalog tasks in our workflow rather than using a script. However, we do create other custom objects using workflow scripts and the same current.variables.VariableName syntax works there (as well as in notifications).



Four our catalog tasks, we put the variables in the task description to display them to the person working the task. The script might look something like this:



var t = new GlideRecord("sc_task");



t.description = "A request for new employee setup has been submitted with the following information:<br /><br />";


t.description += "<h2>New Employee Info:</h2><br />";


t.description += "<b>FirstName:</b> " + current.variables.FirstName + " <b>MI:</b> " + current.variables.MI + " <b>LastName:</b> " + current.variables.LastName + "<br />";


t.description += "<b>Title:</b> " + current.variables.Title + "<br />";


t.description += "<b>Department:</b> " + current.variables.Department.name + "<br />";


t.description += "<b>Personnel Type:</b> " + current.variables.StaffType + "<br />";


t.description += "<b>Employee Classification:</b> " + current.variables.EmployeeClassification + "<br />";


t.description += "<b>Effective Date:</b> " + current.variables.StartDate + "<br />";


t.description += "<b>End Date:</b> " + current.variables.EndDate + "<br />";


t.description += "<b>Supervisor:</b> " + current.variables.Supervisor.name + "<br />";



Hopefully I've correctly understood your question.



Best regards,


Donnie


PJ1
Tera Contributor

Hi,


Thanks for your responce. However my intension is not to access them in script but to display catalog variables [of the request] on the catalog task.



If you create a catalog task by Catalog task activity in workflow, then you have an option to select variables which you want to display on the task. Since i created the tasks by run script i do not have that option, I am looking for a way to do the same through a script.



Thansk,
Prajwal.


ganeshb_
Tera Expert

Hi Prajwal,



You can access the Catalog item variables by using :


current.variables.<variable name>;


OR


If your variables are from variable set then:


current.variable_pool.<variable name>;


e.g var xyz = current.variable_pool.<variable name>;


Thanks,


Ganesh


PrudeAnurag
ServiceNow Employee
ServiceNow Employee

Prajwal,


As far as i have worked with catalog items and creating catalog Task... the variables are not listed on the task... it can be duplicated on the fields designed on the form level.. but the whole new view of Variables(like in Requested item) won't show up there.