NetSuite Purchase Contracts

Has anyone successfully imported Purchase Contracts into NetSuite using the "Item : Additional Pricing" subrecord?  I can't get my mapping to work and don't know what I'm doing wrong.

0

Comments

5 comments
Date Votes
  • Josh Teal are you getting an error?

    0
  • Tyler Lamparter I'm not receiving any errors.  It's just not reading/attempting to import the subsequent lines of the subrecord.  For example, I'm attempting to import a purchase contract with one item and three quantity price breaks for that line item (Additional Pricing subrecord).  In this example my csv file has three lines.  Every column contains the same value except for the subrecord sublist columns.  When I run the flow, it's importing the purchase contract, but only bringing in the first quantity price break (first line in csv).

    0
  • Josh Teal I was able to import a purchase contract with additional pricing. Can you take a look at this flow zip and see if it has something you're maybe missing?

    Sample data I used:

     

    Subrecord setup:

    0
  • Tyler Lamparter Are you using a CSV file as the source?  I'm using a CSV file and importing via Data Loader so the Path to node "lines[*].tiers" doesn't exist and throws an error when I try to use it.  Below is an example of my CSV file.  This represents one Purchase Contract with one line Item with three discount tiers. 

    0
  • Josh Teal I was just using that export as an example. It's best to format this data so it's easier to work with when you get to NetSuite which is why I made an items array with a nested tiers array. For you to do this, you'd need to add grouping to your CSV export and group on External ID. Then I made a transform to get the data in an almost good format (except I had duplicated items now per tier. So then I made a preSavePage script to make each item object a unique item and push each tier into a tier array. For the script, I just used Celigo AI.

    /*
    * preSavePageFunction stub:
    *
    * The name of the function can be changed to anything you like.
    *
    * The function will be passed one 'options' argument that has the following fields:
    *   'data' - an array of records representing one page of data. A record can be an object {} or array [] depending on the data source.
    *   'files' - file exports only. files[i] contains source file metadata for data[i]. i.e. files[i].fileMeta.fileName.
    *   'errors' - an array of errors where each error has the structure {code: '', message: '', source: '', retryDataKey: ''}.
    *   'retryData' - a dictionary object containing the retry data for all errors: {retryDataKey: { data: <record>, stage: '', traceKey: ''}.
    *   '_exportId' - the _exportId currently running.
    *   '_connectionId' - the _connectionId currently running.
    *   '_flowId' - the _flowId currently running.
    *   '_integrationId' - the _integrationId currently running.
    *   '_parentIntegrationId' - the parent of the _integrationId currently running.
    *   'pageIndex' - 0 based. context is the batch export currently running.
    *   'lastExportDateTime' - delta exports only.
    *   'currentExportDateTime' - delta exports only.
    *   'settings' - all custom settings in scope for the export currently running.
    *   'sandbox' - boolean value indicating whether the script is invoked for sandbox.
    *   'testMode' - boolean flag indicating test mode and previews.
    *
    * The function needs to return an object that has the following fields:
    *   'data' - your modified data.
    *   'errors' - your modified errors.
    *   'abort' - instruct the batch export currently running to stop generating new pages of data.
    *   'newErrorsAndRetryData' - return brand new errors linked to retry data: [{retryData: <record>, errors: [<error>]}].
    * Throwing an exception will signal a fatal error and stop the flow.
    */ 
    function preSavePage (options) {
      const data = options.data.map(record => {
        const itemsMap = new Map();
        record.Items.forEach(item => {
          if (!itemsMap.has(item.Item)) {
            itemsMap.set(item.Item, { ...item, Tiers: [] });
          }
          itemsMap.get(item.Item).Tiers.push({
            'From Quantity': item['From Quantity'],
            'Rate or Lot Price': item['Rate or Lot Price']
          });
        });
        record.Items = Array.from(itemsMap.values()).map(item => {
          delete item['From Quantity'];
          delete item['Rate or Lot Price'];
          return item;
        });
        return record;
      });

      return {
        data: data,
        errors: options.errors,
        abort: false,
        newErrorsAndRetryData: []
      };
    }

     

    0

Please sign in to leave a comment.

 

Didn't find what you were looking for?

New post