Hey all i get missing ; error in this script i did...
# suitescript
l
Hey all i get missing ; error in this script i didn't find it 🤣 sorry am new to SDF
Copy code
/**
 *@NApiVersion 2.x
 *@NScriptType UserEventScript
 */

define(['N/record', 'N/log'], function(record, log) {
    function beforeSubmit(context) {

        if (context.type === context.UserEventType.CREATE) {
            // Create a new customer record object
            let customerRecord = record.create({
                type: record.Type.CUSTOMER
            });
            let customFieldId = 'url'; // Replace this with the actual script ID of your custom field

            // Set the value for the custom field
            customerRecord.setValue({
                fieldId: customFieldId,
                value: '<http://www.google.com|www.google.com>' // Replace this with the text you want to fill in the custom field
            });
        }
    }

    return {
        beforeSubmit: beforeSubmit
    };
});
a
I don't see it either... you're getting in this on validate/deploy? are your script objects ok?
l
i get this when i edit the file in NS
a
you get error when you try to edit the file in the file cabinet / on the script record?
l
yes exactly haha i have no idea what am missing
a
share the error?
l
message has been deleted
e
set the NApiVersion to 2.1. If you have Execute Suitescipt 2.x as 2.0 set in general prefs, it's probably choking on the
let
💯 3
a
is this the code AFTER you edit it that generates the error? or is this what it reverts to after the error?
l
@ehcanadian hahah yes that resolved the issue
@Anthony OConnor Thank you so much i changed it to 2.1 lol
that wierd
👍 1
s
perhaps ironically, those should probably be
const
not
let
which IIRC would have slipped past SS 2.0 checking
🤌 1
(even though in 2.0 const doesn't actually do anything)
l
@Shawn Talbert i see i will keep that in mind
s
I almost never use
let
in suitescript.
1
l
Really! only var and const
s
mostly
const
🙂
let
over
var
but with our coding style we almost never need to reach for
let
- as a rule everything can be
const
- unless we really need to mutate a variable in which case
let
stands out like a sore thumb (which is a good thing in that case)
it's helpful that we also let libraries like lodash do much of the heavy lifting, so we don't tend to declare as many temporary variables as some others do.
1
l
@Shawn Talbert Thank you, much appreciated