Is it possible to set Multiselect Field using reco...
# suitescript
a
Is it possible to set Multiselect Field using record.submitFields ??
s
I believe so, what is the syntax of the value you are trying to set/
a
On a project record we have multiselect field which has three values. But when i used record.sumitFields the multiselect field is not setting to any values.
t
I dont believe Multi-Select fields are inline-editable, so technically NetSuite would NOT support the use of record.submitFields() against them even if it does work in practice.
s
Yeah does not seem to be working for me on a random field from teh chrome console.
b
Do it serverside
Or use ss1 client side
k
I think it can be done. Can you send the statement you are using?
Syntax is slightly different when doing via submitField vs record.load / save
This has worked for me:
Copy code
//Array of numerical IDs. Don't think this works if they are strings.
var new_values = [1,2,3];

record.submitFields({
  id: id,
  type: recordType,
  values: { custitem_field: new_values }
});
t
Multi-Select fields are not inline-editable, therefore there is no benefit to using submit fields against them vs loading and saving the record. Governance Implications When you use nlapiSubmitField(type, id, fields, values, doSourcing) as it is intended to be used (to set one or more fields that are inline editable in the UI), the SuiteScript governance cost is 10 units. However, when you use nlapiSubmitField(...) to update fields that are NOT inline editable in the UI, the unit cost for nlapiSubmitField(...) is higher. Your script is charged the units it takes to load and submit a record. For example, the unit cost of nlapiSubmitField(...) to set a non inline editable field on a transaction is: 1. load the record (nlapiLoadRecord) = 10 units 2. set the field = no units 3. submit the record (nlapiSubmitRecord) = 20 units Total = 30 units
s
record.submitFields is 10 units only on transactions (this person is not trying to submit a transaction), and there would be a benefit if they are already using submitFields to set other field values purely from convenience/concise code
t
You missed the point of my message. NetSuite allows you to use submitFields() against fields that are not technically inline-editable in the UI. When you use submitFields() on a non-inline-editable field, the server actually has to load and save the record anyway, so the additional governance cost of that load and save is incurred in that instance. You are welcome to read more about it in help, just search for: Consequences of Using nlapiSubmitField on Non Inline Editable Fields
s
Most people are not concerned with governance usage when trying to update a record, that is my point.
k
It would matter if you were trying to update a number of records. In this case it sounds like governance is not an issue.
@Todd Grimm I didn't realize the record was being loaded anyway. Thanks for pointing that out.
t
Well it would be a bad practice to use it in that instance, because it will not be behaving the way it looks.
s
I would be curious know what the context is on the backend when it uses the load, set and submit for you, edit I assume?
t
yes, I believe it is edit context. * EDIT: Incorrect *
a
@Sandii it worked to me when i used in User Event. But it is not working in chrome console.
t
@Sandii I was mistaken, the context WOULD still be xedit in that case. Sorry for my confusion, couldnt remember all the weird specifics.
s
yeah its a really weird one
Also I just tested it on a custom record using 2.0 (in a UserEvent), and it only used 2 governance units to submit a multi-select field. So it would appear the 1.0 help does not pertain to the 2.0 with regards to governance.
b
Clientside ss2 submitFields doesnt work with multiselects
Its why i said to use ss1 instead,
s
^
a
Context for this is both view and edit. In AfterSubmit function, based on the each selection of the multiselect field I am creating a new task record. so in order to avoid recreating the task on every edit, I am checking a new field for the proof of task creation. So the use case is that users will select one field at a time on each edit which means the value previous select will be erased even though there is a task against the value selected. So when ever this happens based on the number of created task i need to reselect the multiselect fields values.
b
That sounds horrible performance wise
You might want to use a different field
Or perhaps a temporary field added in the beforeLoad
a
yeah I added a temporary field. Thanks
g
@Sandii how do you check how much governance you use?
s
@Gail Kasnett runtime.getCurrentScript().getRemainingUsage()
g
thanks
also do you have any suggested article to read that can shed more light on continuing processing in another deployment if needed?