onSuccess cascade does not retrieve previously id created

hey @SebL !

the onSuccess handler is passed the output data from triggering a query, so you can modify your function there to accept an argument d, or data, or whatever, and then parse fileId out of it:

let afterUpload = function(uploadData) {
  const query = storeFile
  const storeScope = { filename: fileDropzone1.value[0].name }
  query.trigger({ additionalScope: storeScope, onSuccess: afterStore})
}

let afterStore = function(storeData) {
  const query = patchFormationDistributionChannel
  // parse returned data from storeFile query
  const patchScope = { file_id: storeData.result[0].id,
                       formation_id: urlparams.formationId,
                       channel_id: getChannels.data[0].dc_id }
  query.trigger({ additionalScope: patchScope })
}

const uploadScope = { filename: fileDropzone1.value[0].name,
                      filedata: fileDropzone1.value[0].base64Data }

uploadFile.trigger({ additionalScope: uploadScope,
                     onSuccess: afterUpload })

i'll be honest i didn't execute this, i just linted it in VSCode, so it may not run, but sets you on the right track. i'm not a javascript developer either, and they are sometimes elitist about the flow of handlers, so take it as just a suggestion :slight_smile:

5 Likes