1
votes

I have looked at some answers on here and tried putting them into action in my script; but it's not working, and I'm not sure why.

I am trying to update a custom field on an already-existing inventory item. Here is what I have so far

<?php

require_once '../PHPToolkit/NetSuiteService.php';
$service = new NetSuiteService();

$item = new InventoryItem();
$item->internalId = 72309;

$customFieldList = new CustomFieldList();
$customField = new StringCustomFieldRef();
$customField->value = utf8_encode("12345");
$customField->internalId = 'custitem_testinput';
$customFieldList->customField[] = $customField;

$item->customFieldList = $customFieldList;

$request = new UpdateRequest();
$request->record = $item;

$response = $service->update($request);

?>

I'm trying to pull the item record up by its internalID, and then update just 1 of its many custom fields.

This code doesn't error out, but it doesn't seem to do anything either. Looking at the var_dump of the objects, I can see an item object with just the parameters I've set populated, and everything else null.

What am I doing wrong?

1

1 Answers

3
votes

This is a basic example showing how to update custom field in an existing record using PHP toolkit.

<?php
require_once 'PHPToolkit/NetSuiteService.php';

$service = new NetSuiteService();

$ItemId = '72309';
$ItemRecord= new InventoryItem();


//StringCustomFieldRef
$itemField= new StringCustomFieldRef();
$itemField->scriptId = 'custitem_part_lookup';
$itemField->value = 'test';

$customFieldList = new customFieldList();
$customFieldList->customField = array($itemField);

$ItemRecord->internalId = $ItemId ;
$ItemRecord->customFieldList = $customFieldList;

$updateRequest = new UpdateRequest();
$updateRequest->record = $ItemRecord;
$updateResponse = $service->update($updateRequest);

?>

For additional information you can visit Net Suite User Group