Another approach would be to deploy the script tha...
# suitescript
j
Another approach would be to deploy the script that creates the button only to that customer
m
apologies for such a basic question but I'm so very new at this. I looked at the options for deploying the script and I don't see any for limiting it to a customer. Since this script is using the pageinit, would I be on the right track in thinking I could put a condition in the pageinit function of the script to limit it to the relevant customer?
j
Apologies, I'm a little unclear on the requirement is the button only supposed to appear if the sales order uses a particular customer? or is the button only supposed to appear if the user is the customer?
m
It should only appear if the sales order has a particular customer.
j
okay, so I usually add buttons using a beforeLoad user event.
Copy code
function beforeLoad(ctx) {
  ctx.form.addButton(...)
}
My approach in this case would be to check the customer on the order in the user event, and only add the button if it's customer I want
Copy code
function beforeLoad(ctx) {
  var customer = ctx.newRecord.getValue({ fieldId: 'entity' });
  if (customer !== customerThatGetsTheButton) {
    return;
  }
  ctx.form.addButton(...);
m
got it. thank you very much for the guidance!
j
np 👍