This JSON is mapped to an Item Receipt record in NetSuite. One item is 'good', this one will be restocked. The other item is 'damaged', this will be in a receipt in NetSuite but will not be restocked. The Return Auth in NetSuite only has one line item for these two items but the JSON has split the singe item into two.
Is there a way I can do two separate imports, one for the good items and one for the damaged items?
This can't be on one item receipt because the JSON has split the same item into multiple lines depending on the 'good' or 'damaged' status of the item.
> Is there a way I can do two separate imports...?
There might be other ways to modify the records or apply logic, but the answer to your question is yes. See Import filters for more information. Here's the important part for this scenario:
> If there are other downstream [imports], the flow continues to process all records regardless of whether or not they met the import filter criteria.
That's unlike an export filter, in which records filtered out are unavailable for later processing.
> This can't be on one item receipt because the JSON has split the same item into multiple lines depending on the 'good' or 'damaged' status of the item.
Would it help to refactor the JSON in a JS hook so that it consolidates the items into a single line like this instead?
That would merge the items back into one line which doesn't work for the fulfilment record. The NS fulfilment record requires that you specify restock or no-restock on a line item basis so I believe all non-restock items (damaged) would need to be on a separate fulfilment record.
I think Celigo will need to import all the good items in one import then all the damaged goods in another import. The warehouse only sends one JSON message so this all needs to be on one webhook / flow.
I've got a solution where Celigo writes everything to a custom NS record then a SuiteScript can process the fulfilment record. This is by far the easier option for us but means we're reducing the value of Celigo by bypassing some of its functionality.
By setting "One to many" to "Yes", and then setting "Path to many" to point to your "goods" array, there will be one import per array element (ie. in your case, separate ItemReceipts for good and damaged stock). Note that will change your mapping a bit because the "root" for mapping will be the elements in the "goods" array, and you will need to reference elements above "goods" in the JSON hierarchy using {{_PARENT.fieldName}} or {{../fieldName}} notation.
I'm not too familiar with the 'one to many' setting but thought it might create one receipt per line when what we need is two receipts; one for all the good items and one for all the damaged items. I'll play around with that setting in sandbox and see what I can get it to do.
The payload I've included covers the whole usecase, any more and it just gets too complex to communicate and test. I'll let you know how enable that setting goes but my fear is that it will create one receipt for every item. I'll let you know.
I agree with your statement that "Celigo will need to import all the good items in one import then all the damaged goods in another import"
So what I would suggest is that you create 2 item receipts imports but in the mapping you will need to write a compare statement on the items to only use the lines that match your criteria.
Here is an example (note it would have to be tweaked for your exact use case, this is just an example)
That sounds promising. I guess that conditional statement only imports 'good' items then the next import in the flow could do the same but change the condition to look for 'damaged'.
I'll try and implement this in the sandbox environment.