首页 > 解决方案 > 尝试在 NetSuite 中创建两个自定义按钮,一个有效,另一个无效

问题描述

我正在尝试在 NetSuite 中添加第二个自定义按钮来打印项目标签。如果单击第一个按钮,将打开 pdf 模板以打印一张标签。第二个按钮是打开一个模板,为斑马打印机每张打印一个标签。如果我粘贴链接到按钮的地址并手动输入recordId,我可以弹出模板,而不是通过按钮。

用户事件:

function UserEventAddPrintBtn() {
try {
var internalId = nlapiGetRecordId();
var button1 = form.addButton('custpage_button1', 'Print Item Labels (Sheet)',"irlabelBtn()");
//set the internal id of the created Client script.

var button2 = form.addButton('custpage_button2', 'Print Item Labels (Zebra)',"irlabelBtn2()");
//set the internal id of the created Client script.
form.setScript('customscript_atn_client_rec_label');
 
}
catch (exception) {
nlapiLogExecution('DEBUG', 'Error in AddButton()', exception);
}
}

客户端脚本

function irlabelBtn() {
    var recordId = nlapiGetRecordId();
   var baseUrl = '/app/common/custom/advancedprint/printsearchresults.nl?printType=SEARCH&l=T&e=T&id=1150&style=NORMAL&sortcol=Transction_ORDTYPE9_raw&sortdir=ASC&searchid=1150&csv=Export&printtemplate=146&Transaction_INTERNALID=';
    var windowUrl = baseUrl + recordId;
  //alert (recordId);
  
    window.open(windowUrl);
}

function irlabelBtn2() {
    var recordId2 = nlapiGetRecordId();
   var baseUrl2 = '/app/common/custom/advancedprint/printsearchresults.nl?printType=SEARCH&l=T&e=T&id=1150&style=NORMAL&sortcol=Transction_ORDTYPE9_raw&sortdir=ASC&searchid=1150&csv=Export&printtemplate=147&Transaction_INTERNALID=';
    var windowUrl2 = baseUrl2 + recordId2;
  //alert (recordId2);
  
    window.open(windowUrl);
}

标签: htmltemplatesbuttonprintingnetsuite

解决方案


我想通了,检查了我的客户端脚本并且它有效。

function irlabelBtn() {
    var recordId = nlapiGetRecordId();
   var baseUrl = '/app/common/custom/advancedprint/printsearchresults.nl?printType=SEARCH&l=T&e=T&id=1150&style=NORMAL&sortcol=Transction_ORDTYPE9_raw&sortdir=ASC&searchid=1150&csv=Export&printtemplate=146&Transaction_INTERNALID=';
    var windowUrl = baseUrl + recordId;
  //alert (recordId);
  
    window.open(windowUrl);
}

function irlabelBtn2() {
    var recordId = nlapiGetRecordId();
    var baseUrl = '/app/common/custom/advancedprint/printsearchresults.nl?printType=SEARCH&l=T&e=T&id=1150&style=NORMAL&sortcol=Transction_ORDTYPE9_raw&sortdir=ASC&searchid=1150&csv=Export&printtemplate=147&Transaction_INTERNALID=';
    var windowUrl = baseUrl + recordId;
  //alert (recordId2);
  
    window.open(windowUrl);
}


推荐阅读