I am trying to change a field's value on a custom record in a beforeSubmit user event script. I had thought this was possible due to this thread, but it doesn't seem to work. Do beforeSubmit scripts not allow accessing/modifying the record for custom records?
To be precise, the custom record has a legacy text field ("site id") and a new record link field ("site") which links to a customer record. When a user enters a value for the "site id" field, I want to look up the customer with that number and put the internal id into the "site" field. (The legacy field is currently used by an external process through the web service.)
My code is as follows:
function deriveFields(type) { if (type == 'edit') { var siteNum = nlapiGetFieldValue('custrecord_site_id'); nlapiLogExecution('DEBUG', 'test', type + ' ' + siteNum); var search = nlapiSearchRecord('customer', null, new nlobjSearchFilter('entityid', null, 'is', siteNum), new nlobjSearchColumn('entityid')); var siteId = search[0].getId(); nlapiSetFieldValue('custrecord_site', siteId); nlapiLogExecution('DEBUG', 'result', siteId + ' ' + nlapiGetFieldValue('custrecord_site')); } }I am experiencing the following issues when editing a record through the form:[LIST=1][*]nlapiGetFieldValue(...) returns the original value, not the new value the user entered. nlapiGetNewRecord().getFieldValue(...) also returns the same thing.[*]nlapiSetFieldValue(..., ...) seems to have no effect. nlapiGetNewRecord().setFieldValue(..., ...) doesn't seem to do anything either. After executing either, nlapiGetFieldValue(...) still shows the original, unmodified value.[/LIST]Am I using beforeSubmit user event scripts incorrectly? Any help would be appreciated.