在加载时修改Netsuite对象

时间:2013-09-02 12:29:07

标签: encryption netsuite

我对Netsuite很新。我想在Netsuite中进行加密。它在我提交之前添加UserEvent Scripts时有效。但我想在beforeLoad函数中解密加密文本。我能够读取加密文本并成功解密。但是在对象中设置它会失败,我在Netsuite UI中看到了解密文本。任何指示或帮助表示赞赏。

感谢

//此功能有效

功能beforeSubmit(type){

    var email = nlapiGetFieldValue('email');
    var newEmail = 'LifeSpan.' + email;
    nlapiSetFieldValue('email', newEmail );
    nlapiLogExecution('DEBUG', 'Modified before Submit ' + email + ' to ' + newEmail);

}

//打印“在将customercare@abc.com提交至LifeSpan.customercare@abc.com之前修改”

//此功能不起作用;即使正确的值在日志中正确打印

function beforeLoad(type,form,request){

    var email = nlapiGetFieldValue('email');
    if(email.indexOf('SaaSSpan.') != -1) {
      var newEmail = email.substring(9);
      nlapiSetFieldValue('email', newEmail );
    nlapiLogExecution('DEBUG', 'Modified before load ' + email + ' to ' + newEmail);
    }

}

//此印刷品“在加载LifeSpan.customercare@abc.com之前修改至customercare@abc.com”......但我仍然在用户界面中看到LifeSpan.customercare@abc.com

1 个答案:

答案 0 :(得分:0)

我建议您在客户端脚本中尝试此代码(PageInit和SaveRecord事件)。

对我来说很好。

我的代码:

function PageInit(type) {
try {
    if (type == 'edit') {
        var email = nlapiGetFieldValue('email');
        if (email != null && email.indexOf('LifeSpan.') != -1) {
            var newEmail = email.substring(9);
            nlapiSetFieldValue('email', newEmail);
            nlapiLogExecution('DEBUG', 'Modified before load ' + email + ' to ' + newEmail);
        }
    }
}
catch (err) {
    nlapiLogExecution('ERROR', 'PageInit', err);
}}

function SaveRecord() {
try {
    var email = nlapiGetFieldValue('email');
    var newEmail = 'LifeSpan.' + email;
    nlapiSetFieldValue('email', newEmail);
    nlapiLogExecution('DEBUG', 'Modified before Submit ' + email + ' to ' + newEmail);
}
catch (err) {
    nlapiLogExecution('ERROR', 'SaveRecord', err);
}
return true;}

nlapiSetFieldValue可以在用户事件beforeLoad脚本中用于初始化新记录或非存储字段上的字段。