Netsuite | attach detach using .NET webservices
This is a sample code in .NET on how to use the attach/detach method on attaching and detaching a file record to an entity record on Netsuite webservice.
Here is how you can locate the files attached to an employee record:
List > Employees > Employees > Select an employee, in the ‘General’ tab there is a ‘File Cabinet’ subtab.
To locate the files in your Netsuite account:
Documents > Files > File Cabinet
Attaching a file record to an employee record:
//file record
RecordRef recFile = new RecordRef();
recFile.internalId = "373";
recFile.type = RecordType.file;
recFile.typeSpecified = true;
//employee record
RecordRef recEmployee = new RecordRef();
recEmployee.internalId = "470";
recEmployee.type = RecordType.employee;
recEmployee.typeSpecified = true;
//attach class
AttachBasicReference attachBasicRef = new AttachBasicReference();
attachBasicRef.attachedRecord = recFile;
attachBasicRef.attachTo = recEmployee;
WriteResponse response = _service.attach(attachBasicRef);
if (response.status.isSuccess) {
Response.Write("Successfully Attach a file record");
}
else {
Response.Write("Attaching file record, fail");
}
Detaching a file record to an employee record:
//file record
RecordRef recFile = new RecordRef();
recFile.internalId = "373";
recFile.type = RecordType.file;
recFile.typeSpecified = true;
//employee record
RecordRef recEmployee = new RecordRef();
recEmployee.internalId = "470";
recEmployee.type = RecordType.employee;
recEmployee.typeSpecified = true;
//detach class
DetachBasicReference detachBasicRef = new DetachBasicReference();
detachBasicRef.detachedRecord = recFile;
detachBasicRef.detachFrom = recEmployee;
WriteResponse response = _service.detach(detachBasicRef);
if (response.status.isSuccess) {
Response.Write("Successfully Attach a file record");
}
else {
Response.Write("Attaching file record, fail");
}
NOTE: The _service is a NetsuiteService class object. The login process is omitted in this sample code.
Related posts:





What a great blog