Create tasks based on number of inputs in list collector

Pallavi65
Tera Contributor

Hi everyone,

 

I have a list collector field on a catalog item.

User can be able to select n number of values into it.

So let's say for example, user has selected 3 inputs in the list collector field, so for Each input I am trying to create catalog task(one one task for one one input).

So, in the workflow I am using a Run script activity and getting all the inputs of the list collector field and storing in an array.

 

Below pics shows you the exact scenario:

Pallavi65_0-1693477489516.png

 

Pallavi65_1-1693477516845.png

 

 

 

So, can some one help me how to write script in for loop.

like: 

var gr = new GlideRecord('sc_task');

gr.initialize();

gr.request = current.request;

gr.sys_id = current.sys_id;

now: the short description should be like this, (it should populate with first value of the array)

gr.short_description = ar[i];  //here 4Sight as in the above pic that is the first entry of the array.

gr.insert();

 

Like wise I want to create 3 catalog tasks (as the user selected 3 inputs in the list collector)

 

 

Please help me

 

 

Regards,

Pallavi

19 REPLIES 19

Yes Mohith,

 

THere are no spaces. 

Not understanding where it is wrong/

 

@Pallavi65 all three records are there in the table ?

Only one sc_task is getting created when I select 3 applications.

 

Regards,

Pallavi

@Pallavi65 what i meant is all three application records are present in application table with exact names ?

Yes, it's a list collector field. So, we wont type in it manually instead we will select the list of applications from the list which are existing/

(Similar to reference field)

 

 

Regards,

Pallavi