this is a button on transfer order that calls a ...
# suitescript
s
this is a button on transfer order that calls a script why is this coming back as undifend
Copy code
var objRecord = currentrecord.get();
    var wfsshipmenid = objRecord.getValue({ fieldId: "custbody19" });

    console.log(wfsshipmenid);
s
Client scripts do not trigger in view mode, so you only have very basic information from the record such as id/type. If you need more information, then you need to load the record/retrieve in the client script or retrieve/pass that information from the UE button when you call the client script function.
s
how do I pass in the info when you call the client script function.?
Copy code
if (context.type === context.UserEventType.VIEW && check == true) {
      context.form.clientScriptModulePath = "./wfsscript.js";
      context.form.addButton({
        id: "custpage_clickme",
        label: "Get WFS Box label",
        functionName: `wfssuitelet()`,
      });
    }
a
@Sim Greenbaum The functionName does not need ()...
s
before you add your button
var someInfo = // your normal getValue call
then
functionName: 'wfssuitelet(someInfo)'
It's sort of a confusing way to do it, I think just loading the record in the client script is more clear what is going on
s
@Sandii i tried your way which is what i have done until now
Copy code
bootstrap.js:184 Uncaught ReferenceError: someInfo is not defined
s
you do not put the word
someinfo
in there, you need to put whatever value you want in there
s
Copy code
if (context.type === context.UserEventType.VIEW && check == true) {
      var someInfo = "testingonly";
      context.form.clientScriptModulePath = "./wfsscript.js";
      context.form.addButton({
        id: "custpage_clickme",
        label: "Get WFS Box label",
        functionName: "wfssuitelet(someInfo)",
      });
    }
s
someInfo needs to be tha value of the variable
so if using 2.1, you can use tick notation, or like
"wfssuitelet(" + someInfo + ")"
s
still not working
Copy code
Uncaught ReferenceError: testingonly is not defined
s
...
s
also tried this way
Copy code
functionName: `wfssuitelet(${someInfo})`
s
'wfssuitelet("testingonly")'
should work perfectly fine if your value is just a string
liek I said, this syntax is a little confusing, its clearer to just load the record in the client and get the info there
s
I just need one piece of data, to load the record for just that
s
it's up to you, you need to explicitly have quotation marks around your value you are passing in, I assume that is how the api delineates
a
Passing parameters to functionName is not documented and is not official anywhere as far as I know.
s
^ as well
a
It would be a better approach to use a helper Suitelet and pass to the Suitelet what you need, that would have multiple advantages over the use of a Client Script.
s
just some context this is a button on transfer order in view mode.
a button can call a suitelet ?
a
Yes...
s
can you give an example
a
Copy code
var soId = context.newRecord.id;

var href = url.resolveScript({
   scriptId: 'customscript_sl_script_id',
   deploymentId: 'customdeploy_sl_deploy_id',
   params: {soId: soId}
});

context.form.addButton({
   id: 'custpage_my_print_button',
   label: 'Print',
   functionName: '(document.getElementById("custpage_proforma_invoice").onclick = null); (window.location="' + href + '")'
});
s
Seems a bit overengineered when the goal is to pass a singlular string value as parameter to a client script; it's also not really a documented way to handle things. Making a suitelet that takes a parameter to just load/lookup the record anyway... I still think loading/reading in the client is the simplest and most straightforward.
s
in this case i really didn't need the client script as the end goal is a suitelet anyway