0

I'm trying to save a cash sale in netsuite, we have a custom segment field called business unit (ScriptId = custbody_cseg2) and I need to put an specific value to it (Internal Id = 2 in the custom segment).

I'm using the following code who is pretty much the same we have in the netsuite's help but applied to a cash sale transaction:

SelectCustomFieldRef selectCustomFieldRef = new SelectCustomFieldRef();
ListOrRecordRef custSelectValue = new ListOrRecordRef();
custSelectValue.internalId = "2";
//custSelectValue.typeId = "286"; <- with or whitout doesn't change
selectCustomFieldRef.value = custSelectValue;
selectCustomFieldRef.scriptId = "custbody_cseg2";
CustomFieldRef[] customFieldRefArray = new CustomFieldRef[1];
customFieldRefArray[0] = selectCustomFieldRef;
cashSale.customFieldList = customFieldRefArray;

When I run this code I get the following error:

[Code=INSUFFICIENT_PERMISSION] You do not have permissions to set a value for element custbody_cseg2 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.

Do anyone know what would be the error?

Thank you very much!

2 Answers2

1

As its a custom field, check the access level of the field in the custom field creation form. May be you don't have sufficient privilege to edit this field.

Jouhar N
  • 311
  • 1
  • 4
  • I'm running this code with an administrator user, even with the same user I can set this value in the cash sale creation form. – Daniel Forero Aug 24 '17 at 12:14
1

This might be related to your role permissions.

On NetSuite, go to Setup => Users/Roles => Manage Roles. Select the role you are using to access NetSuite through Web Services. Under the Permissions tab, select the "Transactions" subtab and add "Cash Sale". See below image:enter image description here

Charl
  • 812
  • 1
  • 8
  • 22