Skip to content
// Report what happened. The upload runs with "On Error: Continue"; success requires a file id.
const decision = $('Decide Route').first().json;
const up = $input.first().json;
const uploaded = !up.error && Boolean(up.id);
const err = typeof up.error === 'string' ? up.error : up.error?.message ?? null;
return [{
  json: {
    ...decision,
    uploaded,
    file_id: uploaded ? up.id : null,
    file_link: uploaded ? up.webViewLink ?? null : null,
    upload_error: uploaded ? null : err ?? 'no file id returned (check the Google Drive credential and folder ids)',
  },
}];