Articles in this section

Example file transfer: Salesforce to NetSuite

Tips: For handling content from file servers, such as Amazon S3 or FTP, see the respective connector articles.

In this example, the new Salesforce opportunities have associated PDF contracts, which need to be synced into NetSuite along with the accounts. (Although this example relies on built-in connectors, the same concept is used for a generic HTTP connector.)

Example source data

360060659892-sf-ns-files-1.png
360060829231-sf-ns-files-2a.png

Flow progression

{https://docs.celigo.com/hc/article_attachments/360060858491/Salesforce-Files-to-NetSuite.svg}

Configure source

First, create the Salesforce export and define the criteria of the records to sync to NetSuite. Choose Export records from source application.

360060671972-sf-ns-files-3a.png

Edit the export and provide a SOQL query, for example:

SELECT id, Name, phone, fax,  
    (SELECT id, name FROM attachments), 
    (SELECT id, title, body FROM notes)  
  FROM Account WHERE name LIKE 'VL_T%'
360060672192-sf-ns-files-4.png

Observe the Preview data, above. It is important to review and understand the shape of your data retrieved by the query.

JSON output

{
  "attributes": {
    "type": "Account",
    "url": "/services/data/v40.0/sobjects/Account/0015A00002LxEoFQAV"
  },
  "Id": "0015A00002LxEoFQAV",
  "Name": "VL_TEST",
  "Phone": "(510) 555-5555",
  "Fax": null,
  "Attachments": [
    {
      "attributes": {
        "type": "Attachment",
        "url": "/services/data/v40.0/sobjects/Attachment/00P5A00001EeqHDUAZ"
      },
      "Id": "00P5A00001EeqHDUAZ",
      "Name": "file-amendment.pdf"
    },
    {
      "attributes": {
        "type": "Attachment",
        "url": "/services/data/v40.0/sobjects/Attachment/00P5A00001EeqH8UAJ"
      },
      "Id": "00P5A00001EeqH8UAJ",
      "Name": "file-contract.pdf"
    }
  ],
  "Notes": null
}

The two file attributes are highlighted within the Attachments array. Keep this JSON structure in mind, because we will process each array object in the next step.

Configure lookup

Create a lookup to get each file record in the account, so that we can pass the files in a later import. Choose Look up additional files (per record).

360060678032-sf-ns-files-5.png

Since Attachments is an array of files (refer to JSON output above), choose Yes for One to many.

Then, provide the path to the JSON child object Path to many that you want to process multiple times. In this example, the child object is Attachments.

Select the SObject type – in this case Attachment, as shown above:

        "type": "Attachment",

Finally, provide the JSON Id of the Salesforce record to look for. Whenever a lookup step is executed, it operates on one array object at a time; thus, refer to the id as {{data.Id}}.

      "Id": "00P5A00001EeqHDUAZ",
360060680192-sf-ns-files-6a.png

Response mapping

Create response mapping for the lookup and add a new variable, which we’re calling blobKey; use any name you’d like, as long as you are consistent in the rest of the flow’s steps.

Tip

integrator.io assumes that blobKey is the default name for a NetSuite file variable. The advantage to specifying a source record variable name within the response mapping is that the variable is then automatically provided as the default value in the NetSuite file import below.

Give the variable a response field value of data[0].blobKey.

360060853371-sf-ns-files-7.png

The lookup returns a blobKey field as instructed, and we will pass this variable to the next step in our flow by adding this output into the response mapping.

A lookup always returns an array of objects. For each Attachment object, the blobKey field serves as input for the response mapping step.

[
  {
    "blobKey": "a2949b1546ca420798b77297a48a1950",
    "Other attributes" : ...
  }
]

This array of objects is then automatically further wrapped in a data attribute by the response mapping. Hence, we map the value of the new variable to data[0].blobKey.

When this step is completed, the JSON input shown below flows to the next step (importing the files into NetSuite). Note that each attachment now has a blobKey field that holds a reference to the raw file that we fetched from the lookup step.

{
  "attributes": {
    "type": "Account",
    "url": "/services/data/v40.0/sobjects/Account/0015A00002LxEoFQAV"
  },
  "Id": "0015A00002LxEoFQAV",
  "Name": "VL_TEST",
  "Phone": "(510) 555-5555",
  "Fax": null,
  "Attachments": [
    {
      "attributes": {
        "type": "Attachment",
        "url": "/services/data/v40.0/sobjects/Attachment/00P5A00001EeqHDUAZ"
      },
      "Id": "00P5A00001EeqHDUAZ",
      "Name": "file-amendment.pdf",
      "blobKey" : "a2949b1546ca420798b77297a48a1950"
    },
    {
      "attributes": {
        "type": "Attachment",
        "url": "/services/data/v40.0/sobjects/Attachment/00P5A00001EeqH8UAJ"
      },
      "Id": "00P5A00001EeqH8UAJ",
      "Name": "file-contract.pdf",
       "blobKey": "592a17ce5b834d49ba8796f4563c9147"
    }
  ],
  "Notes": null
}

Configure NetSuite file import

For each attachments item found, this step imports the file into the NetSuite file cabinet. Then, it gets the NetSuite fileID so that we can link the IDs with their respective customer accounts (to be created in the next step).

When creating the import, choose Transfer files into destination application.

Create destination_lookup.png

As in the previous flow step, Attachments is an array of files; here, too, choose Yes for One to many. The Path to the JSON child object in this example is again Attachments.

Then, specify the Folder cabinet ID for your NetSuite account connection.

Under the Add operation, provide the Name of each file to be imported in the Handlebars format {{data.Name}}.

Note

Keep in mind that when this step is executed, it operates on one array object at a time. Thus, we refer to the name as {{data.Name}} without any array notation.

Finally, provide a reference to the raw file in the Blob key path field. This value – blobKey – was defined in the response mapping of the previous step, and it appears as the default value in this import.

360060859811-sf-ns-files-9.png

Response mapping

Create a response mapping for this import and add a new variable fileid to receive the ID of each file imported into the cabinet and add it to the data available for the next flow step.

360060860471-sf-ns-files-7b.png

When this step is completed, here is the JSON data that flows into the next step:

{
   "attributes":{
      "type":"Account",
      "url":"/services/data/v40.0/sobjects/Account/0015A00002LxEoFQAV"
   },
   "Id":"0015A00002LxEoFQAV",
   "Name":"VL_TEST",
   "Phone":"(510) 555-5555",
   "Fax":null,
   "Attachments":[
      {
         "attributes":{
            "type":"Attachment",
            "url":"/services/data/v40.0/sobjects/Attachment/00P5A00001EeqHDUAZ"
         },
         "Id":"00P5A00001EeqHDUAZ",
         "Name":"file-amendment.pdf",
         "blobKey":"b1126ef16e0c40e8955f96ec9c9b763b",
         "fileid":"7304"
      },
      {
         "attributes":{
            "type":"Attachment",
            "url":"/services/data/v40.0/sobjects/Attachment/00P5A00001EeqH8UAJ"
         },
         "Id":"00P5A00001EeqH8UAJ",
         "Name":"file-contract.pdf",
         "blobKey":"c499eec2aaca4f9ca26a1114a02ac200",
         "fileid":"7305"
      }
   ],
   "Notes":null
}

Configure NetSuite records and link to file

Create an import that adds sales records in NetSuite and links them with the respective attachments that we imported into the NetSuite folder.

Select Import records into destination application, since we are not using raw files as input in this step.

360060693652-sf-ns-files-10.png

Next, define the record type and operation (Add, Update, or Add or update).

In this example, we want to create a corresponding NetSuite account for each Salesforce account. In other words, one exported record translates into one record in the destination. Here, for One to many choose No.

360060694192-sf-ns-files-12.png

Import mapping

Finally, map an array of attachments to the NetSuite files by passing the file ID, which is stored in the field fileid . Since Attachments is an array, in the import mapping, use Attachments[*].fileid to tell integrator.io to pass the ID to NetSuite.

360060696172-sf-ns-files-13.png

Resulting JSON

{
   "attributes":{
      "type":"Account",
      "url":"/services/data/v40.0/sobjects/Account/0015A00002LxEoFQAV"
   },
   "Id":"0015A00002LxEoFQAV",
   "Name":"VL_TEST",
   "Phone":"(510) 555-5555",
   "Fax":null,
   "Attachments":[
      {
         "attributes":{
            "type":"Attachment",
            "url":"/services/data/v40.0/sobjects/Attachment/00P5A00001EeqHDUAZ"
         },
         "Id":"00P5A00001EeqHDUAZ",
         "Name":"file-amendment.pdf",
         "blobKey":"b1126ef16e0c40e8955f96ec9c9b763b",
         "fileid":"7304"
      },
      {
         "attributes":{
            "type":"Attachment",
            "url":"/services/data/v40.0/sobjects/Attachment/00P5A00001EeqH8UAJ"
         },
         "Id":"00P5A00001EeqH8UAJ",
         "Name":"file-contract.pdf",
         "blobKey":"c499eec2aaca4f9ca26a1114a02ac200",
         "fileid":"7305"
      }
   ],
   "Notes":null
}

Example flow result

360060753472-sf-ns-files-14.png
Was this article helpful?
1 out of 3 found this helpful

Comments

2 comments
Date Votes
  • I am trying to use the example in this article.  However, I am trying to get files attached to an order, i.e. Content documents.  For some reason I continue to get the error "resource not found".

     

     

    0
  • I've taken the action item to verify this article and update as needed. Thanks for bringing it to our attention. For now, it's more pressing to get past that error for your integration requirements, and I would recommend entering a support ticket so that we can analyze your flow. 

    0

Please sign in to leave a comment.