删除工作流在视图上添加的按钮

时间:2017-01-13 23:12:36

标签: netsuite suitescript

我想询问是否可以在记录的查看模式中隐藏工作流添加的按钮。工作流程已锁定,因此无法选择停用操作。

我尝试使用用户事件脚本beforeLoad在记录的查看模式上调用客户端脚本。代码如下:

使用form.setScript的用户事件脚本。

//User Event Script
function callClientScript(type, form) {
    if (type == 'view') {
        form.setScript('customscript_client_script');
    }
}

id为:customscript_client_script:

的客户端
//Client Script
function removeButton() {
    document.getElementById('HTML Id of button to hide').style.display = 'none';
}

不幸的是,这不起作用。我已经研究过,我发现的所有示例都使用一个按钮来绑定客户端脚本,以便在单击时运行。他们在用户事件脚本中添加了这行代码:

form.addButton('custpage_my_button', 'Button Test', 'removeButton()');

我测试过这个并且工作正常。但是,我需要运行" removeButton()"页面加载后自动运行。

1 个答案:

答案 0 :(得分:0)

要实现这一点,您需要使用一些DOM的黑客攻击。您需要使用在beforeLoad期间创建的inlineHTML正文字段注入javascript,并将您的客户端代码作为字符串设置为默认值并由<script>标记包围。

在Suitescript 2.0中有类似的东西:

var injectScriptField = form.addField({
        id : 'custpage_injectscript',
        type : UIMODULE.FieldType.INLINEHTML,
        label : 'Inject Script Field'
    });
injectScriptField.defaultValue = '<script>alert("Hello");</script>';
相关问题