Looking at using the PHPToolkit to transform Sales...
# suitetalkapi
p
Looking at using the PHPToolkit to transform Sales orders into fulfillments for Lot numbered items, I am getting the following error
Copy code
["code"]=>
          string(23) "INSUFFICIENT_PERMISSION"
          ["message"]=>
          string(292) "You do not have permissions to set a value for element inventoryassignment.receiptinventorynumber due to one of the following reasons: 1) The field is read-only; 2) An associated feature is disabled; 3) The field is available either when a record is created or updated, but not in both cases."
As far as I can see all permissions are fine, I have been able to do the fulfilment using this role via the UI, Given the absolute lack of documentation on the toolkit it's a little tricky to guarantee my code, but attached below. Hopefully someone can see the issue
Copy code
$service = new NetSuiteService();

$salesOrderInternalID = "330536";

$reference = new InitializeRef();
$reference->type = InitializeRefType::salesOrder;
$reference->internalId = $salesOrderInternalID;

$record = new InitializeRecord();
$record->type = InitializeType::itemFulfillment;
$record->reference = $reference;

$request = new InitializeRequest();
$request->initializeRecord = $record;

$initResponse = $service->initialize($request);
//vd($initResponse);

if (!$initResponse->readResponse->status->isSuccess) {
    echo "INIT ERROR";
    exit();
}
$itemFulfillment = $initResponse->readResponse->record;

foreach($itemFulfillment->itemList->item as $item) {
//$lineItemId = $item->item->internalId;

    $inventoryAssignment = new InventoryAssignment();
    $inventoryAssignment->quantity = 9;
    $inventoryAssignment->receiptInventoryNumber = "011546";

    $inventoryAssignmentList = new InventoryAssignmentList();
    $inventoryAssignmentList->inventoryAssignment = $inventoryAssignment;

    $inventoryDetail = new InventoryDetail();
    $inventoryDetail->inventoryAssignmentList = $inventoryAssignmentList;

    $item->inventoryDetail = $inventoryDetail;
}

$addRequest = new AddRequest();
$addRequest->record = $itemFulfillment;
$addResponse = $service->add($addRequest);
//vd($addResponse);
if (!$addResponse->writeResponse->status->isSuccess) {
    echo "ADD ERROR";
    exit();
}
$fulfillmentInternalId = $addResponse->writeResponse->baseRef->internalId;
echo "Item Fulfillment created with internal ID: " . $fulfillmentInternalId;
b
create the fulfillment in the ui, load the fulfillment in script, and then get and log the inventory detail of the line
you can also get the item fulfllment via soap webservices and take a look at the response (or web service logs)
p
Getting one via soap does show an object for the inventorynumber, however there isn't a single example on the web that I can find requiring anything deeper than the single assignment
b
compare the inventory detail element from your request to the one from the get
p
The different is the above mentioned inventorynumber object
b
i have no idea what you mean by inventorynumber object
its not a element of an inventory detail
and object in general doesnt mean much for xml
p
I'm working in the context of the PHPToolkit, rather than the standard inventory issue/receipt number being the string for the lot number the one I got via the soap request was an object pulling in an inventory number record
b
what does the issueinventorydetail element look like
p
Copy code
["issueInventoryNumber"]=>
object(RecordRef)#33 (4) {
["name"]=>
string(7) "2942206"
["internalId"]=>
string(4) "8659"
["externalId"]=>
NULL
["type"]=>
NULL
}
b
and lets do a comparison to something you know how to create, in this case the InventoryAssignment
p
this would be the full assignment
Copy code
object(InventoryAssignment)#32 (10) {
["internalId"]=>
string(6) "384752"
["issueInventoryNumber"]=>
object(RecordRef)#33 (4) {
["name"]=>
string(7) "2942206"
["internalId"]=>
string(4) "8659"
["externalId"]=>
NULL
["type"]=>
NULL
}
["receiptInventoryNumber"]=>
NULL
["binNumber"]=>
NULL
["toBinNumber"]=>
NULL
["quantity"]=>
float(1)
["expirationDate"]=>
string(29) "2025-11-06T16:00:00.000-08:00"
["quantityAvailable"]=>
float(128)
["inventoryStatus"]=>
NULL
["toInventoryStatus"]=>
NULL
}
b
you can tell from the first line that the php toolkits represents Inventory Assignment elements as objects of the InventoryAssignment class
that in this case you created using
Copy code
$inventoryAssignment = new InventoryAssignment();
p
indeed
b
to do the same for the issueInventoryNumber, you need to determine the class and then continue on the same way you did for the InventoryAssignment
p
I've somewhat explored that route, maybe incorrectly, but every available example i've found of the toolkit interacting with the inventory detail window it has only passed a string containing the lot number rather than the actual class/object
b
the php toolkit has no special handling for different elements
an InventoryAssignment element is treated the same was as an ItemFulfillmentItem element
which is really just nested objects all the way down
p
Right
b
some elements it represents as primitives
for example a string xml element is just represented as a string in php
the issueInventoryNumber element is not a string, so you need to figure out what type it is
p
Yes, that discovery shall be tomorrows quest I think
b
there are multiple ways to figure it out, i personally just look at the raw xml that netsuite returns its its responses
p
maybe easier working in the raw xml
b
you can also get it from logging the php object that the xml is converted to
i already pointed out earlier where to find the name of the class, thats mostly knowing how php logs things
i dont really know what example you found that tried setting issueinventorynumber with a string, that basically is guaranteed to fail
receiptinventorynumber is set with a string, but issueinventorynumber and receiptinventorynumber arent the same element, and you shouldnt have any expectation that they are the same type
p
was some old code in a discord server, But yes, it was a little odd
I've enabled the logging for now