I have a workflow with two scriptable elements and two variables.
First variable: app_code_csv. Type is MimeAttachment.
Second variable to app_codes. Type is Array/String.
The first scriptable element is titled "Import CSV". It imports the CSV in app_code_csv and assigns the row values to app_codes. Here is the JavaScript code for this element:
System.log("Importing CSV")
var rows = csv.content.split("\n");
app_codes = rows.slice(0,5);
//app_codes = ["3m360","3mcrs","atriad","adaud","dc"];
System.log("App codes list has:")
System.log(app_codes);
System.log("Completed Importing CSV");
The second scriptable element is titled "Compare Lists". It's written in PowerShell. It has a single input, the variable app_codes. It compares the list of app_codes to another list. Here is the PowerShell code:
function Handler($context, $inputs) {
$inputsString = $inputs | ConvertTo-Json -Compress
Write-Host "Starting list comparison"
Write-Host "The values of input.app_codes are:"
Write-Host $inputs.app_codes
$array = @("3m360","3mcrs","atriad","dc","adaud")
Write-Host "The values of the comparison list are:"
Write-Host $array
foreach($ac in $inputs.app_codes){
Write-Host "Checking app code $ac This check should return true."
Write-Host ($ac -in $array)
}
}
This is the log output when I run the workflow. I removed the time stamp and info entries for clarity.
2025-07-02 14:18:08.818 -04:00info__item_stack:/item9
2025-07-02 14:18:10.300 -04:00infoStarting list comparison
2025-07-02 14:18:10.301 -04:00infoThe values of input.app_codes are:
2025-07-02 14:18:10.302 -04:00info3m360 3mcrs atriad dc adaud
2025-07-02 14:18:10.303 -04:00infoThe values of the comparison list are:
2025-07-02 14:18:10.304 -04:00info3m360 3mcrs atriad dc adaud
2025-07-02 14:18:10.305 -04:00infoChecking app code 3m360 This check should return true.
2025-07-02 14:18:10.306 -04:00infoFalse
2025-07-02 14:18:10.307 -04:00infoChecking app code 3mcrs This check should return true.
2025-07-02 14:18:10.308 -04:00infoFalse
2025-07-02 14:18:10.309 -04:00infoChecking app code atriad This check should return true.
2025-07-02 14:18:10.310 -04:00infoFalse
2025-07-02 14:18:10.311 -04:00infoChecking app code dc This check should return true.
2025-07-02 14:18:10.312 -04:00infoFalse
2025-07-02 14:18:10.313 -04:00infoChecking app code adaud This check should return true.
2025-07-02 14:18:10.314 -04:00infoFalse
The PowerShell code supposedly has two identical arrays of Strings, yet comparing each element in the first array (app_codes) to see if it's in the second array returns false.
In the first scriptable task's code, notice line 5 is commented out. That line manually makes an array, disregarding the CSV input, and assigns it to app_codes. If I uncomment that line, here's the log output:
2025-07-02 14:24:47.658 -04:00info__item_stack:/item9
2025-07-02 14:24:49.103 -04:00infoStarting list comparison
2025-07-02 14:24:49.104 -04:00infoThe values of input.app_codes are:
2025-07-02 14:24:49.105 -04:00info3m360 3mcrs atriad adaud dc
2025-07-02 14:24:49.106 -04:00infoThe values of the comparison list are:
2025-07-02 14:24:49.107 -04:00info3m360 3mcrs atriad dc adaud
2025-07-02 14:24:49.108 -04:00infoChecking app code 3m360 This check should return true.
2025-07-02 14:24:49.109 -04:00infoTrue
2025-07-02 14:24:49.110 -04:00infoChecking app code 3mcrs This check should return true.
2025-07-02 14:24:49.111 -04:00infoTrue
2025-07-02 14:24:49.112 -04:00infoChecking app code atriad This check should return true.
2025-07-02 14:24:49.113 -04:00infoTrue
2025-07-02 14:24:49.114 -04:00infoChecking app code adaud This check should return true.
2025-07-02 14:24:49.115 -04:00infoTrue
2025-07-02 14:24:49.116 -04:00infoChecking app code dc This check should return true.
2025-07-02 14:24:49.117 -04:00infoTrue
The values of the two arrays are the same, but now the comparison operator returns True.
Why does a manually created array get assigned to a variable and passed properly, while an array imported through csv.content.split not?