Skip to content

Instantly share code, notes, and snippets.

@PiotrKrzyzek
Created April 22, 2020 20:06
Show Gist options
  • Save PiotrKrzyzek/7888c929e8fae1cc602c4ead4d713559 to your computer and use it in GitHub Desktop.
Save PiotrKrzyzek/7888c929e8fae1cc602c4ead4d713559 to your computer and use it in GitHub Desktop.
Zapier Array Split
// for inputData set:
// keys = the array's list of key values (Such as when WooCommerce sends of two arrays for one array of data. Such as "metakeys"
// values = is the array's value list
// of course, you can modify this easy to simply accept one array ... or as many as you'd like.
// Currently, this code does NOT do any error checking (other than exists()) nor sanitization
output = {
'the_output_field_label_here': '',
}
if( inputData.keys ){
var keys = inputData.keys.split(',');
var values = inputData.values.split(',');
if( keys.indexOf('additional_field_107') > 0 ) {
output['the_output_field_label_here'] = values[keys.indexOf('additional_field_107')];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment