I am unable to set a field of type INLINEHTML using SuiteScript 2.0. However, the same field works with SuiteScript 1.0. Here is the code snippet:
/**
* @NApiVersion 2.x
* @NScriptType ClientScript
*/
// In SuiteScript 2.0
define(['N/search'], function(search) {
return {
pageInit: function(context) {
var currentRecord = context.currentRecord;
// Set Value (This does not set any data)
currentRecord.setValue({ fieldId: 'inline_html_field', value: '<div>Test Value</div>' });
// Get value (Returns undefined)
currentRecord.getValue({ fieldId: 'inline_html_field'});
}
}
});
// In SuiteScript 1.0
nlapiGetFieldValue('inline_html_field'); // Returns the data in field
Unfortunately this is an instance where the logic implemented behind the record.getValue() or the currentRecord.getValue() in SS 2.0 is flawed. In SS 1.0 a nlapiGetFieldValue() passes through less validation than the SS 2.0 counterpart. Here is an example (hopefully changed enough that NetSuite doesn't throw me in jail for violating their IP). This is what is happening when you request the value.
function getTheValue(options)
{
var fieldId;
fieldId = '....';// Do a bunch of logic to validate the options parameter is correct
return doGetTheValue(fieldId);
}
function doGetTheValue(fieldId)
{
var fieldObj = goodOlegetField(fieldId); // goodOle being our 1.0 api prefix....
// the function call above returns null preventing your request from succeeding.
var value;
if (fieldObj == null)
return undefined;
}
I hope this makes sense, and although it isnt an answer it will provide insight as to why you are getting the response you are getting. Its also solid validation that you are not crazy. I have frequently found I need this reassurance when working with SS 2.0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With