Hello, Im having some issues with this code, for s...
# suitescript
i
Hello, Im having some issues with this code, for some reason I cant call the suitelet, when I click the button it doesnt do anything, checking the chrome console it gives me this error
Uncaught SyntaxError: missing ) after argument list
I’ve done everything that I could think of to try and fix this but I just cant, if on the params I send an empty
object
it works but when trying to send the fields object I get that error, I’ve tried
JSON.stringify, toJSON(), String()
but nothing seems to work, this is some sample data that Im sending:
{
custrecord_bit_freight_terms: "Collect",
custrecord_bit_cm_purchase_order: "PO000000",
custrecord_bit_ein: "ein",
custrecord_bit_ship_export: "\r\nU ZZZZ 27\r\nPardubice  532 01 \r\nCountry",
custrecord_bit_carnet_required: "2",
custrecord_bit_ship_via: "FEDEX Int'l Freight Economy",
custrecord_bit_incoterms: "Origin Warehouse",
custrecord_bit_customer_purchase_order: "/ N/A",
custrecord_bit_revision: "6",
custrecord_bit_invoice_no: "SO12345",
custrecord_bit_special_instructions: "Memo Test  A11111111",
custrecord_bit_pdf_status: true,
custrecord_bit_ior: "1555 XXXX B.V. XXXXXXX Amsterdam  11111 CT NL",
custrecord_bit_date_of_exportation: "2019-12-19T08:00:00.000Z",
custrecord_bit_ctry_export: "Czech Republic"
}
b
its extremely likely that your code isn't working because you are basically creating a string to be passed to eval
f
createFieldsObject is not closed properly, you're missing a bracket before the return statement
b
assuming you get passed that bracket, you still need to fix the eval string thing
the string in suiteletPDFCreationURL needs to be escaped
all
'
characters need to be escaped with
\'
this must be done since your eval string contains
"FEDEX Int'l Freight Economy"
as an alternative, consider adding a script to the form using Form.clientScriptModulePath (https://system.na2.netsuite.com/app/help/helpcenter.nl?fid=section_4625445350.html)
and use the function you defined in the script you added for your button
keep in mind that the functionName you use when you add the button should match the key used in the object you return in the script you added
i
Awesome! Thanks for the help guys!
An update yes, that
FEDEX Int'l Freight Economy
string was the issue, the
'
part, I tried to escape it using the backslash but for some reason was still not working, what I end up doing was replacing all the special characters using
.replace(/[^a-zA-Z ]/g, "")
I still need to fix this because this is targeting all special characters, but for now this solved the issue
b
if it helps
you are also supposed to escape the escape character
\
preferably before you escape
'
im not sure if it would be an issue since i think the url escaping might have handled that already
you can try sharing what your failed escape for
'
looked like