The post response map hook is invoked on a page of records after response or results mapping. This hook is a great place to execute logic on batches of records to optimize the response/results data to be merged back into the source records. For example:
- Perform calculations using the results of a lookup, and then discard the lookup data
- Sort, group, and filter records returned by a lookup
- Remove or restructure response fields returned in the _json response data object
Function stub
/*
* postResponseMapFunction 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:
* 'postResponseMapData' - an array of records representing the page of data after response mapping is completed. A record can be an object {} or array [] depending on the data source.
* 'responseData' - the array of responses for the page of data. An individual response will have the following fields:
* 'statusCode' - 200 is a success. 422 is a data error. 403 means the connection went offline.
* 'errors' - [{code: '', message: '', source: ''}]
* 'ignored' - true if the record was filtered/skipped, false otherwise.
* 'data' - exports only. the array of records returned by the export application.
* 'id' - imports only. the id from the import application response.
* '_json' - imports only. the complete response data from the import application.
* 'dataURI' - imports only. a URI for the data in the import application (populated only for errored records).
* 'oneToMany' - as configured on your export/import resource.
* 'pathToMany' - as configured on your export/import resource.
* '_exportId' - the _exportId currently running.
* '_importId' - the _importId currently running.
* '_connectionId' - the _connectionId currently running.
* '_flowId' - the _flowId currently running.
* '_integrationId' - the _integrationId currently running.
* 'settings' - all custom settings in scope for the export/import currently running.
* 'job' - the job currently running.
* 'testMode' - Boolean flag that executes script only on test mode and preview/send actions.
*
* The function needs to return the postResponseMapData array provided by options.postResponseMapData. The length of postResponseMapData MUST remain unchanged. Elements within postResponseMapData can be changed however needed.
* Throwing an exception will signal a fatal error and fail the entire page of records.
*/
function postResponseMap (options) {
return options.postResponseMapData
}