我无法使用SuiteScript 2.0设置INLINEHTML类型的字段。但是,同一字段适用于SuiteScript 1.0。
这是代码片段:
/**
* @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
最佳答案
不幸的是,在这种情况下,SS 2.0中的record.getValue()或currentRecord.getValue()背后实现的逻辑存在缺陷。在SS 1.0中,nlapiGetFieldValue()通过的验证少于SS 2.0对应的验证。这是一个示例(希望已进行了足够的更改,以使NetSuite不会因为违反其IP而将我送入 jail )。当您请求该值时,这就是发生的情况。
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;
}
我希望这是有道理的,尽管这不是一个答案,但它将为您提供为何获得响应的见解。它也有力的印证您没有发疯。我经常发现使用SS 2.0时需要这种保证。
关于javascript - 在SuiteScript 2.0中从客户端脚本设置内联HTML字段,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45933536/