require_once '../PHPToolkit/NetSuiteService.php';
$service = new NetSuiteService();
$imgPath = "C:\Users\hguerrero\Documents\Helloworld.docx";
$imgContents = file_get_contents($imgPath);
$Message = new Message();
$MediaItem = new MessageMediaItemList();
$nsFile = new File();
$nsFile->folder = new RecordRef();
$nsFile->folder->internalId = '-10';
$nsFile->name = 'HelloWord.docx';
$nsFile->fileType = '_WORD';
$nsFile->attacFrom = '_computer';
$nsFile->content = $imgContents;
$MediaItem->mediaItem = $nsFile;
$Message->author = new RecordRef();
$Message->author->internalId = '1';
$Message->author->type = 'customer';
$Message->recipient = new RecordRef();
$Message->recipient->internalId = '384';
$Message->recipient->type = 'contact';
$Message->messageDate = '2013-10-28T00:50:39.301Z';
$Message->subject = 'Case';
$Message->message = 'Message 101';
$Message->emailed = 'true';
$Message->activity = new RecordRef();
$Message->activity->internalId = '413';
$Message->activity->type = 'supportCase';
$Message->mediaItemList = $MediaItem;
$request = new AddRequest();
$request->record = $Message;
$addResponse = $service->add($request);
if (!$addResponse->writeResponse->status->isSuccess) {
echo "ADD ERROR";
} else {
echo "ADD SUCCESS, id " . $addResponse->writeResponse->baseRef->internalId;
}
Wednesday, May 15, 2019
PHP Toolkit New Version (2012.2 and Later) > Ability to Add Message with File Attachment
Below is a sample code that will create a message and attach a file on it using PHP Toolkit (WS)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment