我无法使用 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/