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

Thank you that was a great catch, much appreciated Chaitanya