Need Help With PreSave Script
I have a requirement that Celigo support said would require a preSave script. I'm not sure how to implement this in my data loader flow using a csv file to Netsuite.
I have rows in a csv that represent a cash refund transaction. Each row has header data and line item data. A refund will typically have just two rows - an invoice row and an adjustment row denoted by a field called “invoice_type”. The line item data on each row has an item and an amount.
My requirement is to check the invoice_type and if it equals “adjustment” then I want to map the item amount from that row into a header field on the cash refund.
According to the support person, I need to use a preSave script to modify the data to put the value of the refund_type = adjustment outside the array. I have no idea how or where to do this.
Comments
Hi Martin Hambalek,
I've moved your post to the Troubleshoot custom flows section for more visibility. Here are some resources on the pre save script and how to use it.
Hi,
If I understand correctly, your CSV file contains one invoice line and one adjustment line for each cash refund transaction.
In the data loader settings, you can first group the data so that the invoice and adjustment lines are grouped together into one array. This will make it easier to process both lines as part of a single transaction:
For example, after grouping, your data would look like this:
Next, you can add a transform script to process the adjustment and map its amount to the header field.
Here’s an example of the script you can use:
This script will produce the following output:
Does this help?
Please sign in to leave a comment.