Thursday, June 6, 2019

Workflow or Script Not Updating Field Via Mass Update / Fields are Blank

Mass update runs in the context of xedit (inline editing).  This means that only fields being updated are accessible.  There are different ways around this:
1.  Include the field that need to be access in the mass update.
2.  Use a workflow action script instead of just a workflow.  See #3 and #4.
3. Instead of using nlapiSetFieldValue use nlapiSubmitField.  Example below for updating the email on a customer record:
    var id = nlapiGetRecordId();
    nlapiSubmitField('customer', id, 'email', '');
4. If any of the fields being set are part of a sublist or if the value of fields not being updated are normally gotten with nlapiGetFieldValue then first load the record using nlapiLoadRecord.  Example below:
    var memo = nlapiGetFieldValue('memo');
    nlapiSetLineItemValue('item', 'quantity', 1, 5);
    var id = nlapiGetRecordId();
    var rec = nlapiLoadRecord('salesorder',id);
    var memo = rec.getFieldValue('memo');
    rec.setLineItemValue('item', 'quantity', 1, 5);
Note: Calling nlapiLoadRecord and nlapiSubmitRecord will increase the time the mass update takes as it will cause the record to saved twice instead of just once.

DISCLAIMER: The sample code described herein is provided on an "as is" basis, without warranty of any kind, to the fullest extent permitted by law. NetSuite Inc. does not warrant or guarantee the individual success developers may have in implementing the sample code on their development platforms or in using their own Web server configurations.
NetSuite Inc. does not warrant, guarantee or make any representations regarding the use, results of use, accuracy, timeliness or completeness of any data or information relating to the sample code. NetSuite Inc. disclaims all warranties, express or implied, and in particular, disclaims all warranties of merchantability, fitness for a particular purpose, and warranties related to the code, or any service or software related thereto.
NetSuite Inc. shall not be liable for any direct, indirect or consequential damages or costs of any type arising out of any action taken by you or others related to the sample code.

No comments:

Post a Comment