javascript - 在 SuiteScript 2.0 中从客户端脚本设置内联 HTML 字段

标签 javascript netsuite suitescript2.0

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

相关文章:

pdf-generation - 免费标记中的 NetSuite 子公司值(value)比较

NetSuite SCA 触发用户事件

通过 externalId 搜索 NetSuite API

javascript - LibGDX html 剪贴板

javascript - javascript中的字符串连接问题

javascript - jQuery,来自类的触发事件

javascript - SuiteScript 中的 ID 字段抛出 INVALID_FLD_VALUE

NetSuite-套件脚本 : Rescheduling a Map/Reduce script to Run after a specific time on failure

javascript - 工厂返回相同的值