if I have a button that calls custom function can ...
# suitescript
s
if I have a button that calls custom function can i pass in parameters to it like this
Copy code
var rec = context.newRecord     context.form.addButton({
        id: "custpage_clickme",
        label: label,
        functionName: `createshippinglabel(${rec})`,
      });
b
how familiar are you with eval
s
When i was in school we were taught to never use
b
good, thats basically where we are
its a bad idea
but thats how you are using it
your functionName is equivalent to evaluating that string
s
so if i need the id and type pass it in as 2 strings
b
you could if you want to load the record
depending on how this is being used, you may also be able to use N/currentRecord
s
the button call a script which is only in my file cabinet will "N/currentRecord" work ?
b
depends what you want from the record
in view mode, you basically only get the id and type
in edit or create you get everything
s
the record is in view mode and I need a lot of the data till now I was using record. load,
does it make sense to use both module curent record to get type and id and record to load the full record ?
b
if you wanted to avoid playing with the function name string, then yes
s
lol yes i want to avoid
@battk thanks a bunch