Display catalog variables on task form

madeves
Kilo Contributor

There are a lot of questions regarding workflow and variables but none that seem to answer my question.

 

I am using a workflow to create a task from a Requested Item.   This is a facilities task.   I am trying to pass the variables completed on the form onto the Facilities task but I cannot seem to get this to work.   I don't want to use a record producer.

 

Has anyone got any suggestions please?

17 REPLIES 17

You can use an Order Guide to Order Your original items.


I was suggesting creating a Record Producer to Create your Facilities task (it would NOT be seen by the user).   In your WF you would use the script that spawns the Record Producer.   The script is in this link: Order a Service Catalog Item from a Script - ServiceNow Wiki.   HOWEVER, once I looked at this script; I don't think it will work with a Record Producer.   IT uses the 'cart' which Record Producers do NOT.



I would move back to paul_erics solution of writing your variables to the Description field on the Facilities task.


madeves
Kilo Contributor

Thanks for this.   I will give it a go.


there is a script in the mail templates that puts all of the variables on the email.. it would seem like you could adapt that script to work in a workflow.


madeves
Kilo Contributor

Ah yes - I have used the script for my emails.   I will try and adapt to workflow. Many thanks.


justin_drysdale
Mega Guru

The workflow should have access to the variables from the form.   Make a run script event and log out the values:



Run Script:


var members = current.variable_pool,


      collector;


     


for (h in members) {


  var abc = members[h];


  if (abc != "") {


  collector += "\n" + abc + "\n";


  }


}


gs.log(collector);



Your logs should show the variable values listed in no particular order.   If you can see the values that means the workflow has


access to them.   From there you can use a run script to create the record on the facilities table:



Run Script:


var fac = new GlideRecord('facilities_table_name');


      fac.initialize();


      fac.<facilities_variable> = current.variable_pool.<form_variable>;


      //etc...


      fac.insert();