Heya, very new to netsuite and trying to get my head around all the moving parts. I'm trying to do a little project to get some experience with scripting within netsuite but due to my ignorance what to google or what to look for in the docs is not helping me a great deal.
I'm going to step back a little bit and describe the problem I'm trying to solve just in case the scripting aspect of it would be totally unnecessary and could be handled using standard netsuite features.
Problem: Sales rep enters a sales order that includes our store's promotion of 5% off >$500, 10% off >$1000, 15% off >$1500. Right now we can apply a promotion that calculates the total discount and subtracts this amount from the gross total. If a customer returns an item (from a multiple-item order and wants a partial refund, it's not immediately clear how much the customer should be refunded to the sales rep processing the refund).
Possible way of solving the problem: Apply the promotional discount as an item-by-item discount and reduce the price of the item by the respective % rather than having a nebulous 'total discount' amount subtracted from gross total.
I have a naive idea about how this might be doing with Suitescript, but I'm hoping you guys can point me in a better direction.
Here's my naive approach idea: Add a button to the sales order form, that, when pressed, iterates over all the items that have been added to the sales order and adjusts each of their prices to the appropriately discounted amount.
However, when I was looking through the docs, I couldn't wrap my head around just how this might be possible. I was looking at N/ui/serverWidget's addButton method, but that looked to me like it was for a custom form (almost like a form that was being put together completely via script, rather than a preexisting form).
I then noticed that I could edit the Sales Order form directly and noticed the Actions/Custom Actions tab, but the more I looked into that, it seemed like I would be working more with a WorkFlow Script as opposed to a Client Script, but the docs/example kept referring to the WorkFlow manager and the example wanted me to add a custom field... well as far as I could tell the Sales Order form I was editing wasn't part of a WorkFlow --- oof. I was able to add a button via a Custom Action but couldn't figure out how to connect the associated function to anything (as far as I could understand it needed to be added to a specific WorkFlow, then could be associated with the form).
I would greatly appreciate some pointers in the right direction! Then I can bug you guys about when a script has access to
context
, how to iterate over a sublist and so much more 🙂 Thanks!