How to capture retry data with preSavePage hook



  • Tyler Lamparter Principal Product Manager
    Awesome Follow-up
    Top Contributor
    Answer Pro
    Celigo University Level 4: Legendary

    Krunal Patel you need to put your error and record data within the newErrorsAndRetryData field. Make sure to follow the instructions of the preSavePage script stub. See modified script and sample error output:

    * preSavePageFunction stub:
    * The name of the function can be changed to anything you like.
    * The function will be passed one 'options' argument that has the following fields:
    *   'data' - an array of records representing one page of data. A record can be an object {} or array [] depending on the data source.
    *   'files' - file exports only. files[i] contains source file metadata for data[i]. i.e. files[i].fileMeta.fileName.
    *   'errors' - an array of errors where each error has the structure {code: '', message: '', source: '', retryDataKey: ''}.
    *   'retryData' - a dictionary object containing the retry data for all errors: {retryDataKey: { data: <record>, stage: '', traceKey: ''}}.
    *   '_exportId' - the _exportId currently running.
    *   '_connectionId' - the _connectionId currently running.
    *   '_flowId' - the _flowId currently running.
    *   '_integrationId' - the _integrationId currently running.
    *   'pageIndex' - 0 based. context is the batch export currently running.
    *   'lastExportDateTime' - delta exports only.
    *   'currentExportDateTime' - delta exports only.
    *   'settings' - all custom settings in scope for the export currently running.
    * The function needs to return an object that has the following fields:
    *   'data' - your modified data.
    *   'errors' - your modified errors.
    *   'abort' - instruct the batch export currently running to stop generating new pages of data.
    *   'newErrorsAndRetryData' - return brand new errors linked to retry data: [{retryData: <record>, errors: [<error>]}].
    * Throwing an exception will signal a fatal error and stop the flow.
    function preSavePage(options) {
      let newErrorsAndRetryData = [];
      let errors = [];
      for (var i = 0; i <; i++) {
        try {
          if (![i].SERVICENOW_SYS_ID.length >= 1) {
            throw new Error('CustomerSYSID not found');
        } catch (e) {
            errors: [{
              "code": "Customer SYS ID not found",
              "message": "Customer ID Error with record: " +[i].CONTRACT_LINE_ID,
              "source": +[i].CONTRACT_LINE_ID

      return {
        errors: options.errors,
        abort: false,
        newErrorsAndRetryData: newErrorsAndRetryData

  • Krunal Patel

    Thank you so much Tyler Lamparter. I wasn't aware we needed push retry data to newErrorsAndRetryData.


Please sign in to leave a comment.