Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>When editing an existing record, <code>nlapiSetFieldValue</code> cannot be used in a Before Load event on fields that are stored with the record. From the function's JSDocs:</p> <blockquote> <p>Sets the value of a given body field. This API can be used in user event beforeLoad scripts to initialize field on new records or non-stored fields.</p> </blockquote> <p><code>nlapiSetFieldValue</code> can thus only be used reliably in Before Load on new records or non-stored fields.</p> <p>Realizing this is a month old so you've probably found a solution, I would move your code to the Before Submit event. I tested this using a Scheduled Script:</p> <pre><code>var customer = nlapiLoadRecord('customer', '31294'); nlapiSubmitRecord(customer); </code></pre> <p>and User Event on the Customer record, Before Submit event:</p> <pre><code>if (nlapiGetContext().getExecutionContext() === 'scheduled') { nlapiSetFieldValue('url', 'http://www.google.com/', false); } </code></pre> <p>This works as expected for me in a 2013.1 Sandbox environment.</p> <p>Using <code>nlapiSubmitField</code> in After Submit as mentioned in the other answer is an unnecessarily long operation that will use extra governance units. Not a huge deal if that's the only thing your script is doing, but if you ever expand the script or add looping, it can add up quickly in terms of performance and governance usage.</p> <p>Also, it may not be necessary, but you should ensure that <code>getDiscountVal</code> is a <code>Number</code> by doing:</p> <pre><code>var getDiscountVal = parseInt(nlapiGetFieldValue('discountrate'), 10); </code></pre> <p>If it comes back as a <code>String</code> then your division operation may give a strange result which may also cause <code>nlapiSetFieldValue</code> to fail or set the field to an odd value.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload