英文:
General steps to add button to page in NetSuite?
问题
请问有人能帮助我添加一个按钮到估算表单吗?
我只需要关于如何做这件事的一般步骤(尽管我会感激有人提供更多详细信息)。
我尝试创建一个客户端脚本,但它没有'N/ui/serverWidget'模块(显然在客户端脚本中不可用)。
除此之外,我如何创建一个按钮而不会弄乱并直接修改DOM,我不知道。
在此提前致谢。
英文:
could anyone please, assist me with a request to add a button to an Estimate form?
I need only general steps on how to do it (although I'd appreciate if someone provided more details).
I tried to create a client script, but it doesn't have the 'N/ui/serverWidget' module (apparently it's not available in the client scripts).
How otherwise I can create a button w/o creating a mess and directly modifying the DOM — I don't know.
Thank you in advance.
答案1
得分: 1
你可以在用户事件脚本中使用 beforeLoad()
事件来将按钮添加到记录的表单中。您还可以指定一个客户端脚本,其中包含按钮点击时要执行的逻辑。
let form = context.form;
form.clientScriptModulePath = '{{pathToYourClientScript}}';
form.addButton({
label: '这是按钮标签',
id: 'custpage_button_id',
functionName: 'functionFromYourClientScript'
});
用户事件脚本需要部署到目标记录类型(估算)。客户端脚本不需要为此进行部署;它只需要在文件柜中的form.clientScriptModulePath
参数指定的位置可用。您还可以选择使用 clientScriptFileId
属性来指定客户端脚本。functionName
属性指定了来自您的客户端脚本的函数,该函数将绑定到按钮上。这个(客户端)函数将在按钮点击时执行。
英文:
You would use a beforeLoad()
event in a User Event script to add the button to the record's form. You can also specify a client script, which will contain the logic to be executed when the button is clicked.
let form = context.form;
form.clientScriptModulePath = '{{pathToYourClientScript}}';
form.addButton({
label: 'This is the button label',
id: 'custpage_button_id',
functionName: 'functionFromYourClientScript'
});
The User Event script needs to be deployed on your target record type (Estimate). The client script does not need to be deployed for this; it just has to be available in the file cabinet at the location specified in the form.clientScriptModulePath
parameter. You can optionally specify the client script using the clientScriptFileId
property instead. The functionName
property specifies the function from your client script, which will be bound to the button. This (client) function will execute when the button is clicked.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论