Action to produce an array help needed

Stephencroc
Mega Guru

I have the following Action I'm trying to create to do the following:
1.  Take in a string of numbers (this will be sys_id's from the question_choice table that is connected to a catalog item - List item).
2. convert the comma separated sys_ids to an array

3.  Output the array so I can loop. over that with a decision table.

 

I have the following so far:
For Inputs:

Stephencroc_0-1762964238707.png

for the script action:

Stephencroc_1-1762964265417.png

Script:

(function execute(inputs, outputs) {
  
  // Read the comma-separated list input
  var csv = inputs.ampModule || '';

  // .split(',') will give an array of strings
  var arr = csv.split(',');
    
  // Set the output array variable
  outputs.modulearray = arr;
  
})(inputs, outputs);

 

Outputs

Stephencroc_2-1762964352931.png

I'm not sure what's going on but when I create this an run a test with just numbers like 1111,2222,3333 I get an array back but it's empty.  Not sure why, could someone help with this please.

1 ACCEPTED SOLUTION

Chaitanya ILCR
Mega Patron

HI @Stephencroc ,

 

you should be using "inputs.sapModule" instead of inputs.ampModule in the 4th line of the script

 

try this script

(function execute(inputs, outputs) {
  
  // Read the comma-separated list input
  var csv = inputs.sapModule || '';

  // .split(',') will give an array of strings
  var arr = csv.split(',');
    
  // Set the output array variable
  outputs.modulearray = arr;
  
})(inputs, outputs);

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

View solution in original post

5 REPLIES 5

Mohammed8
Giga Sage

hi @Stephencroc 

 

Your input not matching with input you provided in script, please cross check once. Shouldn't it be sapModule?

 

var csv = inputs.sapModule || '';

 

 Try aligning both the input name properly 

 

Please mark this helpful/solution accepted, if you find this useful

 

Regards,

Mohammed Zakir

Had no difference, I put in '1111','2222','3333' and still got a blank array returned

Hi @Stephencroc ,

 

Your scripts run fine after i made input variable change.

 

Mohammed8_0-1762966095069.png

 

Please mark this helpful/solution accepted, if you find this useful

Regards,

Mohammed Zakir

 

Chaitanya ILCR
Mega Patron

HI @Stephencroc ,

 

you should be using "inputs.sapModule" instead of inputs.ampModule in the 4th line of the script

 

try this script

(function execute(inputs, outputs) {
  
  // Read the comma-separated list input
  var csv = inputs.sapModule || '';

  // .split(',') will give an array of strings
  var arr = csv.split(',');
    
  // Set the output array variable
  outputs.modulearray = arr;
  
})(inputs, outputs);

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya