postSubmit Hook

In the example below, there is a filter on the import that excludes certain records.  I was attempting to add a hook inside the import (I used postSubmit) to determine whether the record passed through this import or was skipped.  The script simply adds a new object with the value of yes to the responseData and then the response mapping picks up that value and adds it into the source record.

It appears that all records pass through this hook even if they were filtered out at the beginning of the import step because all records are getting the new object = yes added to them.  Is this correct and if so, how should I structure the flow such that I can tell whether the record passed through this particular step?

0

Comments

4 comments
Date Votes
  • Michael Gantt that is correct. Hooks run on the entire page of data so that you can easily perform any action against all records. For postSubmit, here is an example of me filtering 1 of 2 records and this is the input of my postSubmit script. You can see that everything is available prior to mapping (in my preMap array), then it gets filtered and the postMap array has the second record as null since it was filtered out. Lastly, in the responseData, you have an ignored boolean field if it was ignored, but no ignored field if it wasn't. The index position of all these arrays align to each other.

    {
        "preMapData": [
            {
                "test": 1
            },
            {
                "test": 2
            }
        ],
        "postMapData": [
            {
                "test": 1
            },
            null
        ],
        "responseData": [
            {
                "statusCode": 200,
                "_json": {
                    "test": 1
                },
                "_headers": {
                    "date": "Fri, 14 Jun 2024 14:24:10 GMT"
                },
                "errors": []
            },
            {
                "statusCode": 200,
                "_json": {},
                "ignored": true,
                "errors": []
            }
        ],
        "settings": {
            "import": {}
        },
        "configuration": {},
        "_connectionId": "637527a77f409d08acc91d00",
        "_flowId": "666c5208ca868a0797b98842",
        "sandbox": false,
        "testMode": false,
        "_importId": "666c522077c163306fa42cf7"
    }

    0
  • Thank you, that helped me get what I needed.  In the flow example you sent, how did you get the sample data at the exact spot you wanted (the postSubmit input)?

    0
  • Michael Gantt in the script, I added console.log(JSON.stringify(options)); as the first line in my function, then I ran the flow, went to the scripts tab on the flow, clicked the 3 dots, clicked view execution log, and clicked refresh.

     

    0
  • Perfect, thanks again!

    0

Please sign in to leave a comment.

 

Didn't find what you were looking for?

New post