Is it possible to add a button on a ue sublist whi...
# suitescript
c
Is it possible to add a button on a ue sublist which calls a paramaterized function on a client script?
b
you can use anything that is valid for a button's onClick property
c
so I’ve tried to call a method via onClick which exists in a client script but I can’t figure out how to reference it correctly. do you know of a workaround?
ah… button’s onClick… hmmm….
b
standard procedure is to do something like the following for the user event
Copy code
/**
 * @NApiVersion 2.0
 * @NScriptType UserEventScript
 * @NModuleScope SameAccount
 */
define(["exports"], function (exports) {
  exports.beforeLoad = function (context) {
    context.form.addButton({
      label: "Battk's Button",
      id: "custpage_battk_button",
      functionName: "battkButton",
    });
    context.form.clientScriptModulePath = "./button.js";
  };
});
and have the client script look like:
Copy code
define([], function () {
  return {
    battkButton: function () {
      alert("i was added in beforeLoad");
    },
  };
});
c
Oh.. I’m sorry. I’m trying to put a button on a sublist row. I tried an href link with my func name in the onClick but the func on the client script is not in global scope.
b
than make your client script add to the global context
Copy code
define([], function () {
    this.battkButton = function () {
      alert("i was added in beforeLoad");
    }
});
if you aren't using an actual client script and dont have the jsdoc up top, you can use window
c
hot damn