On form.addButton, can you add a parameter to your...
# suitescript
x
On form.addButton, can you add a parameter to your function name?
b
You can do the equivalent of hardcoding a value when you call your button function
For example you could use
functionName:'button(123)'
x
Ok, so in that case, if I wanted to have a suitelet run in a window.open( ) as a result of that function call, all I would need to do is put the URL of that suitelet, and have the client script open that URL?
b
Potentially, id probably try generating the url from the client script before putting it in the functionName
x
@battk My user event script seems to not be triggering the client script on this. I can show code if you want
b
sure
x
var form = context.form;
var scriptURL = url.resolveScript({
scriptId: 'customscript_sc_bs_docengine',
deploymentId: 'customdeploy1',
returnExternalUrl: true,
params: { "jrecid" : context.newRecord.id }
});
log.debug({
title: 'scriptURL',
details: scriptURL
});
form.addButton({
id: 'custpage_btn_call_docengine',
label: 'Test',
functionName: "openWindow(" + scriptURL + ");"
});
context.form.clientScriptModulePath = "SuiteScripts/Libraries/docengineclient.js"
Can confirm that the docengineclient.js is in the correct folder in the file cabinet
And here's the client code:
/**
* @NApiVersion 2.x
* @NScriptType ClientScript
*/
define(["N/ui/dialog", "N/log"], function (dialog, log) {
function pageInit(context) {
// TODO
}
function openWindow(url) {
log.debug({
title: 'we made it',
details: url
});
window.open(url);
}
return {
pageInit: pageInit,
openWindow: openWindow
}
});
b
look in your browser's console when you press the button
there should be an error, because the technique you are using is essentially using eval
x
Uncaught SyntaxError: missing ) after argument list
b
you can try logging the string you use for the functionName to see the code
but im going to once again recommend you put the url generating code in the client script
x
Better now - the script is opening the new window.
159 Views