The CreatorCon Call for Content is officially open! Get started here.

Task short description from list collector variable

Lucy10
Tera Contributor

Hi,

Im able to create individual task from the values from the list collector but this issue im having is displaying the list collector value in the task short description.

Script below:

var abc = [];

var abc = current.variables.apps.toString();

var xyz = [];

var xyz = abc.split(',');

var length = xyz.length;

for(var i=0; i<length;i++){

  var task = new GlideRecord("sc_task");

  task.initialize();

  task.parent = current.sys_id;

  task.short_description = current.variables.request_type.getDisplayValue() + " Aplication access: " + xyz[i];   // the issue: I believe im just getting the sys ID

  task.description = current.variables.comments;

  task.request=current.request;

  task.request_item = current.sys_id;

  task.assignment_group = '179e890737deb640ad36616043990e14';

  task.insert();

  }

Thanks,

Lucy

1 ACCEPTED SOLUTION

larstange
Mega Sage

Hi



Yes a list collector is essentially just a comma seperated list of sys_ids



You can either


  1. Get the display value of the list collector: var abc = current.variables.apps.getDisplayValue();
  2. Or in the for loop get a gliderecord for each sys_id in the table your list collector is pointing to
    var gr = new GlideRecord('list_collector_table');
    gr.get(xyz[i]);
    task.short_description = current.variables.request_type.getDisplayValue() + " Aplication access: " + gr.getDisplayValue();



Option 1 is only possible, if the display values of the records in your list collector does not contain commas


View solution in original post

4 REPLIES 4

larstange
Mega Sage

Hi



Yes a list collector is essentially just a comma seperated list of sys_ids



You can either


  1. Get the display value of the list collector: var abc = current.variables.apps.getDisplayValue();
  2. Or in the for loop get a gliderecord for each sys_id in the table your list collector is pointing to
    var gr = new GlideRecord('list_collector_table');
    gr.get(xyz[i]);
    task.short_description = current.variables.request_type.getDisplayValue() + " Aplication access: " + gr.getDisplayValue();



Option 1 is only possible, if the display values of the records in your list collector does not contain commas


Lucy10
Tera Contributor

Thanks Lars


dj21
Giga Expert

The list collector values filled in the catalog form are stored as sysids(Variable Ownership table). I doubt you can dotwalk to the table fields or get the display value.


anurag92
Kilo Sage

You might need to add 1 more GlideRecord in above code to get display value:



task.parent = current.sys_id;


var getAppsValue= new GlideRecord('appsTable'); //the table which apps variable is referring to


getAppsValue.addQuery('sys_id',xyz[i]);


getAppsValue.query();


if(getAppsValue.next())


  task.short_description = current.variables.request_type.getDisplayValue() + " Aplication access: " + getAppsValue.name;