<@U5TF1GQ20> "Uncaught SyntaxError: Invalid regula...
# suitescript
x
@battk "Uncaught SyntaxError: Invalid regular expression flags"
b
your script variable is terribly escaped
rather than try and fix it, i say just open a window
so remove the script variable entirely
x
@battk. Getting warmer, but I really need to pass that record ID parameter.
I can confirm that my suitelet is being called now, though.
b
whats your code?
x
function itemReceiptPDF(type, form) {
if (type == 'view')
{
var recID = nlapiGetRecordId();
var suiteletURL = nlapiResolveURL('SUITELET', 'customscript_mn_ir_pdf_suitelet', 'customdeploy1');
suiteletURL += '&param1=' + recID;
var script = "window.open(nlapiResolveURL('SUITELET', 'customscript_mn_ir_pdf_suitelet', 'customdeploy1') + '&param1=nlapiGetRecordId()');"
form.addButton('custpage_viewpdf', 'Print', script);
}
}
This is where it stands as of this moment. In the debugger, I see param1, but it's coming back as a string of that getRecordId function.
b
oh
thats your suitelet code
dont do it like that
attach a client script
make the object it returns contain code to open your window
x
Oh no, the code you're seeing is a beforeLoad on a UE.
My suitelet is being called correctly, but I'm having issues passing the internal ID of the record.
b
same idea
set the client script to have a function that you use as the functionName
x
So it should read something like form.addButton('x', 'x', functionName(recordID))) functionName(id) { //suitelet code }
b
i personally prefer just functionName()
and have your clientscript function do the work
your code will be prettier when transitioned to ss2
x
Yeah. I could have done it in ss2, but I was just lazy, haha.
function itemReceiptPDF(type, form) {
if (type == 'view')
{
var recID = nlapiGetRecordId();
var suiteletURL = nlapiResolveURL('SUITELET', 'customscript_mn_ir_pdf_suitelet', 'customdeploy1');
suiteletURL += '&param1=' + recID;
form.addButton('custpage_viewpdf', 'Print', 'resolvePDFSuitelet()');
}
}
function resolvePDFSuitelet() {
window.open(nlapiResolveURL('SUITELET', 'customscript_mn_ir_pdf_suitelet', 'customdeploy1') + '&param1=' + nlapiGetRecordId());
}
It's saying resolvePDFSuitelet is not defined.
b
Did you add the client script to the form
x
to the form variable you mean?
add resolvePDFSuitelet to a client script
set that client script on the form
x
@battk Just did that. Says the function doesn't exist.
b
what does your setScript call look like
x
Ohhhh, I misread what you meant by add it to the form. I thought you meant attach it to the custom form.
I've never used that function before. Would I have to create a new Client Script record, and set the function as a Page Init?
b
you have to create a new client script record, with a script file containing your resolvePDFSuitelet function
you do not need to set event functions
use setScript and set it to one of the ids of your newly created client script
if you did this in ss2, you could skip creating the script record and would only need to create the script file