Apisero is now part of NTT DATA - Learn more.

Search
Close this search box.

Attach/Detach Documents From NetSuite File Cabinet To A Specific NetSuite Record

Author: Hemanjali Sood

In this blog, we’ll go through how to use NetSuite’s attach/detach connector step-by-step to smoothly connect various file types from the File Cabinet to specific records within the NetSuite system.The File Cabinet serves as a centralized repository for storing files, documents, and other media in NetSuite.This blog post will guide you through the process of leveraging this feature to optimize your workflow and improve collaboration across your organization.

Attaching Documents to NetSuite Records using ATTACH Connector:
  1. Set the input for the attach connector in Xml format.

For attaching the files we need 2 internal Ids :-

  • Internal Id of the file from File Cabinet which we wanted to attach (for example its 1917 for me).
  • Internal Id of the Record in which we need to attach the file (for example its 846867 for me).

(NOTE: In NetSuite, the Internal ID is a unique identifier assigned to each record within the system. It serves as an internal reference for a variety of documents, including such as customers, transactions, items, employees, vendors, and more. The Internal ID remains consistent and does not change, even if the record’s name or other attributes are modified.

We can get the internal Id of the document while uploading it in File Cabinet and internal Id of the record can be obtained after creating it or searching it from its NetSuite Id).

Also, you need to put the “type” of record in “attachTo” according to the type of record you are using to attach the file (for example I am attaching the file in a SalesOrder Record).

(NOTE : Keep the “type” of record in camelcase for example “salesOrder” in my case)

%dw 2.0
output application/xml
ns ns0 urn:messages.platform.webservices.netsuite.com
ns ns01 urn:core.platform.webservices.netsuite.com
ns ns02 urn:customization.setup.webservices.netsuite.com
ns xsi http://www.w3.org/2001/XMLSchema-instance
ns ns03 urn:sales.transactions.webservices.netsuite.com
---
{
	ns01#attach: {
		ns0#attachReference @("xmlns:ns01": ns01 , xsi#"type": "ns01:AttachBasicReference"): {
			ns01#attachTo @(internalId: <internal Id of record>,"type": <type of record>,xsi#"type": "ns01:RecordRef"): {
			},
			ns01#attachedRecord @(internalId: <internal Id of file>,"type": "file", xsi#"type": "ns01:RecordRef"): {
			}
			}
	}
}
  1. Add the ATTACH Connector and configure “Attachment type” as “AttachBasicReference” and provide input payload in “Message”.
  1. Convert the output payload into json format.

OUTPUT : – After running the application our file named “Test” in pdf format from file cabinet will get attached to our Salesorder record.

Detaching Documents to NetSuite Records using DETACH Connector:
  1. Set the input for the detach connector in Xml format. 

For detaching the files we need 2 internal Ids : –

  • Internal Id of the file from File Cabinet which we wanted to detach(for example its 1917 for me).
  • Internal Id of the Record from which we need to detach the file(for example its 846867 for me).

Also you need to put the “type” of record in “detachFrom” according to the type of record you are using to detach the file (for example I am detaching the file from a SalesOrder Record).

%dw 2.0
output application/xml
ns ns0 urn:messages.platform.webservices.netsuite.com
ns ns01 urn:core.platform.webservices.netsuite.com
ns ns02 urn:customization.setup.webservices.netsuite.com
ns xsi http://www.w3.org/2001/XMLSchema-instance
ns ns03 urn:sales.transactions.webservices.netsuite.com
---
{
	ns01#detach: {
		ns0#detachReferece @("xmlns:ns01": ns01 , xsi#"type": "ns01:DetachBasicReference"): {
			ns01#detachFrom @(internalId: <internal Id of record>,"type": <type of record>,xsi#"type": "ns01:RecordRef"): {
			},
			ns01#detachedRecord @(internalId: <internal Id of file>,"type": "file", xsi#"type": "ns01:RecordRef"): {
			}
			}
	}
}
  1. Add the DETACH Connector and provide “Detach ref type” as “DetachBasicReference” and give the input payload in “Message”.

3. Convert the output payload into json format.

OUTPUT : – 

We use cookies on this site to enhance your user experience. For a complete overview of how we use cookies, please see our privacy policy.