Monday, January 28, 2019

Web Services > Attaching File to Support Case via the Attach Operation

The following code below is sample code on attaching a File to a Support Case within NetSuite. Please note that you need a valid login session to be able to attach a file to a support case. This example is for a console based application

Also the NetSuite Service Object is required to perform any operation to NetSuite via Web Services.

NetSuiteService nss = new NetSuiteService();

// Specifies the file, the file must be in the file cabinet – the file's internalID in this case is 1.
RecordRef recFile = new RecordRef();
recFile.internalId = "1";
recFile.type = RecordType.file;
recFile.typeSpecified = true;

// Specifies the support case based on the internal ID of the support case.
RecordRef recSupport = new RecordRef();
recSupport.internalId = "2";
recSupport.type = RecordType.supportCase;
recSupport.typeSpecified = true;

// Attaches the file to the support case.
AttachBasicReference abr = new AttachBasicReference();
abr.attachedRecord = recFile;
abr.attachTo = recSupport;

// Send the process to NetSuite and returns a response.
WriteResponse res = nss.attach(abr);

// checks if the file was attached or not
if (res.status.isSuccess)
{
Console.Write("File is Attached successfully");
}
else
{
Console.Write("File is not attached successfully");
}

No comments:

Post a Comment