admin管理员组文章数量:1323556
Hi i am trying to add a button in a standard form by using a user event triggered function but it didn't alert me.
function clickMe() {
alert('Button was clicked from "+nlapiGetRecordType()+" in VIEW mode');
}
function myBeforeLoad(type, form, request) {
var customButton=form.addButton('custpage_mybutton','MyFirstButton','clickMe();');
}`
Hi i am trying to add a button in a standard form by using a user event triggered function but it didn't alert me.
function clickMe() {
alert('Button was clicked from "+nlapiGetRecordType()+" in VIEW mode');
}
function myBeforeLoad(type, form, request) {
var customButton=form.addButton('custpage_mybutton','MyFirstButton','clickMe();');
}`
Share
Improve this question
edited Jul 16, 2016 at 10:38
HiDeoo
10.6k8 gold badges51 silver badges49 bronze badges
asked Jul 16, 2016 at 9:30
ashbaq1ashbaq1
451 silver badge8 bronze badges
5 Answers
Reset to default 2Is your clickMe
function defined in your User Event or your Client script? In order to be executed from a button click, the function must exist on the client side, so you need to define it in a client script.
You need to attach your script to the form. You can do this by using form.setScript(nlapiGetExecutionContext().getScriptId());
The script needs to be applied to the form before you create the button and set the function you want to call from the ClientScript.
if (type == 'view')
{
form.setScript('customscript_asw_ss_cs_member');
form.addButton('custpage_mybutton','MEMBERSCRIPT','onclick_callAlert()');
}
While generally the better way to do this is with a separate client script like the other answers, for a simple one-liner you can get away with hard coding the script into a string, e.g.
function myBeforeLoad(type, form, request) {
var script = "alert(\'Button was clicked from \' + nlapiGetRecordType() + \' in VIEW mode\');";
var customButton = form.addButton('custpage_mybutton','MyFirstButton',script);
}
This is user event script
function myBeforeLoad(type, form) {
if (type=='view'){
var customButton = form.addButton('custpage_mybutton','MEMBER SCRIPT','onclick_callAlert()');
form.setScript('customscript_asw_ss_cs_member');
}
}
This is Client Script
function onclick_callAlert()
{
alert('hi');
}
Thanks For You All Replies....
本文标签: javascriptAdding Button in standard form in netsuiteStack Overflow
版权声明:本文标题:javascript - Adding Button in standard form in netsuite - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742120576a2421674.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论