# Tip - PreMap vs. PostResponseMap with One-to-Many Imports

**URL:** <https://connective.celigo.com/t/tip-premap-vs-postresponsemap-with-one-to-many-imports/5485>\
**Category:** Integrator.io\
**Tags:** script, lookup\
**Created:** [September 17, 2025, 11:37am UTC](https://connective.celigo.com/t/tip-premap-vs-postresponsemap-with-one-to-many-imports/5485 "2025-09-17T11:37:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![khutijatasneemmohamm](https://avatars.discourse-cdn.com/v4/letter/k/ea666f/32.png) [@khutijatasneemmohamm](https://connective.celigo.com/u/khutijatasneemmohamm)\
**Post date:** [September 17, 2025, 11:37am UTC](https://connective.celigo.com/t/tip-premap-vs-postresponsemap-with-one-to-many-imports/5485/1 "2025-09-17T11:37:17Z")

</div>

When working with **preMap scripts** in [integrator.io](http://integrator.io), it’s easy to assume that the script applies to the entire dataset you pass in. But things behave a little differently when you enable the **One-to-Many** option on an import step.

This happened while I was working on a project to move data between **DealCloud (Intapp) and Reprisk using CSV files from FTP**, and I thought it would be useful to share what I learned.

### What I expected:

I had a file via FTP with more than 100 records.  
I wrote a **preMap script** , assuming it would let me run logic across the entire file **before the mappings and before the data reached the import step.**

### What actually happened:

Once I enabled _One-to-Many_ on the import step, I realized something important:

- The preMap script only applies to each grouped record, meaning the logic I wrote was running per record (or per group), **not on the original full array of records from the file.**
- This meant that any logic depending on the entire data/dataset simply didn’t work the way I expected.

So instead of running once across all 100+ records, my script was only acting inside each smaller grouped set of records.

### The solution I found:

Instead of using preMap, _I switched to a postResponseMap before the import step_ - this turned out to be more accurate, especially for a lookup step.

- postResponseMap gives you access to the data after your export but before the import.
- This meant I could apply my logic to the entire dataset, not just individual grouped records.
- Once transformed, the data flowed into the import step exactly as needed.

**The result: my logic worked across the full dataset, just the way I originally intended.**

### Quick Tip for Debugging:

If you ever don’t know what data your script is getting, you can use **`console.log()`** to print the data. This shows you exactly what’s coming in and makes it much easier to fix problems.

**Key takeaways :**

- preMap is great when your logic only needs to act on each individual record.

- With One-to-Many enabled, remember that preMap sees only the grouped records, not the full dataset.

- Use postResponseMap when you need to apply transformations to the entire dataset before import.

- Always test small batches first - it’s easier to see whether your logic runs per record or per group.

This small adjustment saved me a lot of debugging time. Hopefully it helps others avoid the same confusion !!!!
