RE: Select an entry in a custom list

Hi

 

I’m adding a stock adjustment to NetSuite via the Web service PAI.

The stock adjustment has a custom list of adjustment reasons.

We import this custom list into our system so the user can select the appropriate reason when they make the adjustment.

When I add the inventory adjustment correctly except the reason from the custom list is always the first item on that list which I assume it is defaulting to.

Each time we process the stock adjustments I get the custom list from NetSuite.

var list = ImportReasons(db);

Then for the stock adjustment being procesed I find the appropriate CustomListCustomValue object.

CustomListCustomValue selectedReason = (from l in list.customValue
where l.valueId == adjustment.Reason.ValueID
select l).FirstOrDefault();

I create an InventoryAdjustment object and then assign the selectedReason to its customList property.

 

var reason = new SelectCustomFieldRef()
{
scriptId = “customlist_reason_code”,
value = new ListOrRecordRef()
{
internalId = selectedReason.valueId.ToString()
}
};

inventoryAdjustment.customFieldList = new CustomFieldRef[] { reason };

 

I’m assuming that list last is what’s wrong but don;t know how to correct it.

Can anyone help.

Thanks

Steve

 

SteveRowlands Rookie Asked on August 4, 2020 in How To's.

Is it possible for you to share the XML request that is being generated from this code?

on August 4, 2020.

Sorry for the delay in replying below is the body of the xml message received by NetSuite <soap:Body> <add xmlns=”urn:messages_2019_2.platform.webservices.netsuite.com”> <record xsi:type=”q1:InventoryAdjustment” xmlns:q1=”urn:inventory_2019_2.transactions.webservices.netsuite.com”> <q1:account internalId=”1660″/> <q1:inventoryList> <q1:inventory> <q1:item internalId=”3966″/> <q1:location internalId=”34″/> <q1:adjustQtyBy>10</q1:adjustQtyBy> </q1:inventory> </q1:inventoryList> <q1:customFieldList> <customField scriptId=”customlist_reason_code” internalId=”2″ xsi:type=”SelectCustomFieldRef” xmlns=”urn:core_2019_2.platform.webservices.netsuite.com”> <value internalId=”2″/> </customField> </q1:customFieldList> </record> </add> </soap:Body>

 

The internal id used in the custom field is fro mthe list pulled from netsuite:

Damaged 1
Stock Count Error 2
Rework 3
Obsolescence 4
Work Order Closure Error 5
Shrinkage 6
Internal Consumption 7

 

although we send a 2, the stock adjustment appears on netsuite as Damaged.

on August 12, 2020.
Add Comment
1 Answers

Hi Steve,

For the benefit of others browsing this question (I’m Steve’s colleague!), we were using the wrong scriptId. It was the correct one to use to get the values but to pass it back in the inventory adjustment we needed to use a different script id. Using the value as the internal ID was correct.

Phill

Rookie Answered on September 9, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.