How do I cancel a NetSuite import if there are no line items to import?

Comments

6 comments

  • David Gollom Strategic Partner
    Top Contributor
    Celigo University Level 4: Legendary
    Answer Pro
    Great Answer
    Engaged

    Can you filter on your items array in the JSON object from the 3PL and make sure it's Not Empty in a Input filter to the NetSuite import??

    0
  • José Díaz Hernández
    Engaged

    The inbound JSON will never be empty. There will always be hundreds / thousands of line items with quantities on hand for goods at the 3PL. However, prior to import to NetSuite, I perform a lookup to NetSuite to check on quantities on hand. I then compare to the quantities in the inbound JSON in the import's pre map hook and throw out any line items where the quantity difference is 0. So I need to be able cancel the import if there are no line items left once that comparison is made.

    But you did give me an idea. I can try to do the comparison in a postResponseMap hook right after the lookup, keep a running tab of the net quantity difference for the entire inventory adjustment. If it's 0, then I can use the input filter you are talking about! I think that should work!

    0
  • José Díaz Hernández
    Engaged

    Unfortunately, custom settings are read-only. Does anyone know if there is a way to set up a global variable scoped to the flow or its execution that I can access through hooks? That might give me what I need. I tried to access with a postResponseMap hook post lookup my line item data as part of an array within the record object but that's not how the postResponseMapData appear to be formatted. This is what I got instead:

    {
      "postResponseMapData": [
        {
          "_PARENT": {},
          "ProductCode": "6516388DD-NOV-18DD",
          "LocationType": "Available Stock",
          "Quantity": 9,
          "NSQtyOnHand": "8"
        }
      ],
      "_exportId": "630f877d78aab87cba1b1323",
      "_connectionId": "62abe22e2fd46c408f127591",
      "_flowId": "630f85803f8b5a4960280bdc",
      "_integrationId": "6307b3cb27887910c1d0f026",
      "settings": {
        "integration": {
          "style": "6516602",
          "testMode": false
        },
        "flowGrouping": {},
        "flow": {},
        "export": {},
        "connection": {}
      }
    }

    I was hoping to get it in this format.

    {
      "data": [
        {
          "StockQuantityLineItem": [
            {
              "ProductCode": "6516602-BLK-08",
              "LocationType": "Available Stock",
              "Quantity": 106
            },
            {
              "ProductCode": "6516602-BLK-10",
              "LocationType": "Available Stock",
              "Quantity": 150
            },
            {
              "ProductCode": "6516602-BLK-12",
              "LocationType": "Available Stock",
              "Quantity": 237
            },
            {
              "ProductCode": "6516602-BLK-14",
              "LocationType": "Available Stock",
              "Quantity": 319
            },
            {
              "ProductCode": "6516602-BLK-16",
              "LocationType": "Available Stock",
              "Quantity": 208
            },
            {
              "ProductCode": "6516602-BLK-18",
              "LocationType": "Available Stock",
              "Quantity": 74
            },
            {
              "ProductCode": "6516602-MDN-08",
              "LocationType": "Available Stock",
              "Quantity": 10
            },
            {
              "ProductCode": "6516602-MDN-10",
              "LocationType": "Available Stock",
              "Quantity": 23
            },
            {
              "ProductCode": "6516602-MDN-12",
              "LocationType": "Available Stock",
              "Quantity": 32
            },
            {
              "ProductCode": "6516602-MDN-14",
              "LocationType": "Available Stock",
              "Quantity": 34
            },
            {
              "ProductCode": "6516602-MDN-16",
              "LocationType": "Available Stock",
              "Quantity": 34
            },
            {
              "ProductCode": "6516602-MDN-18",
              "LocationType": "Available Stock",
              "Quantity": 12
            }
          ]
        }
      ],
      "errors": [],
      "abort": false,
      "newErrorsAndRetryData": []
    }

    If I could get it in this format, I could weed out the line items with 0 difference in 3PL quantity and NetSuite quantity and use the input filter suggested above. Unfortunately, I can only get my data in this format in the preSave hook for the export and the preMap hook for the import.

    Any words of wisdom?

    0
  • Scott Henderson CTO
    Celigo University Level 1: Skilled
    Answer Pro
    Top Contributor

    You should be able to format the records however you like using the postResponseMap hook (just like with the preSavePage hook), and instead of trying to write to a custom setting (which are read only in the context of a hook execution), you can always add new fields to the records in the postResponseMapData array.  i.e. You can add a boolean field called something like 'hasInventoryChanges = true/false'.

    Taking a step back, you can also ignore records in the preMap and postMap hooks.  If you read the function stub docs very carefully, it says the following.  Hope this helps!

    * Returning an empty object {} for a specific record will indicate that the record should be ignored.

    0
  • José Díaz Hernández
    Engaged

    Thank you, Scott. There are a couple of really good options you've provided. I'll create a variable local to the hook called hasInventoryChanges and then return an empty object if false. Awesome suggestions!

    0
  • Steve Klett Strategic Partner
    Celigo University Level 4: Legendary
    Answer Pro
    Great Answer
    Top Contributor
    Awesome Follow-up
    Engaged

    Returning an empty object {} for a specific record will indicate that the record should be ignored.

    I like this option because it leverages the native behavior of IIO

    0

Please sign in to leave a comment.