options.files[] missing in PreSavePage script when evaluated by "flow editor"
It was difficult to come up with a title that concisely described the issue. I'm posting this here as an FYI to the community and a bug report to Celigo. Reporting bugs via support is too difficult, but I want to get the bugs logged so hopefully this is an effective method.
Symptom: Input preview for Input Mapping or script editor has no records. You check the previous step Transform, Output mapping, Pre Save Page script - they all have valid input and output previews. The following Import step?.... nothing.
The scenario:
- Export step has a Pre Save Page script works with the options.files array, copies filenames and asserts there is precisely 1 file in the array. This works perfectly fine when editing the script and previewing it.
- The following Import step has no record data in it's Input previews
- Disabling the Pre Save Page script causes data to appear in the Import previews again
Logging the serialized options parameter in the Pre Save Page shows what the problem is; there's no files[] property on the options object when the script is evaluated in the flow. Again, this is hard to explain. I'm sure if I RUN the flow, it will be fine, but when I'm editing the flow and IO evaluates the flow to generate the Input previews, it is omitting the file[] array. This in turn causes the scrip to throw an error and downstream Input previews are blank.
The only solution I can find is to code the Pre Save Page script to expect a missing files[] array. This isn't right, I don't like writing weak code with undefined behavior like this, but what choice do I have?
Expected behavior: Pre Save Page is called with the same options object during runtime/editing as it gets when editing the script.
The script is very simple!
function onPreSavePage (options) {
// Copy the export filename to the record so it's part of the retry data and maybe we'll
// save on the record in NetSuite in case we need to investiage what happened.
options.data.forEach(record => {
// There should always be a filename, if there isn't we want to throw because that's completely unexpected
if (options.files.length !== 1) {
throw `Expected exactly 1 file record but found ${options.files.length}`
}
record._ediFilename = options.files[0].fileMeta.fileName
})
return {
data: options.data,
errors: options.errors,
abort: false,
newErrorsAndRetryData: []
}
}
Comments
Hi Steve Klett,
Thank you for reporting this, we'll have our team look into it and fix it in a future release. Appreciate the help!
Hey Steve,
Could you please ensure that you also return the "files" field from the onPreSavePage function? You could also make the necessary changes to the data and return the "options" JSON as it is, so that nothing is missed, like the function below. Please let us know if this is working for you.
Thanks,
Emmy
Please sign in to leave a comment.