I think whatever you want to do can be done by using Suitescript. The SuiteScript API includes several Record APIs that interact with the entire NetSuite record object. When you work with Record APIs, you are doing things such as creating, deleting, copying, or loading all elements of a record.
Whether you are working with standard NetSuite records (for example, Sale Order, Invoice, Customer, Vendor) or custom records you have created using SuiteBuilder, you will use all the same Record APIs to interact with the record object.
The elements of mostly records in NetSuite, include fields, subtabs, sublists, sublist fields, and buttons.
So in order to add a button on SalesOrder you first need to load its element i.e. button and then fire an event on it and call a function. and perform the operation in function.
Following are the steps to Run a User Event Script in NetSuite:
-------------------------------------------------------------------------------------
To run a user event script in NetSuite, you must:
1. Create a JavaScript file for your user event script.
2. Load the file into NetSuite.
3. Create a Script record.
4. Define all runtime options on the Script Deployment page.
******************** Following sample code Generates a Record Log ********************
This user event script creates an execution log entry containing the type, record type, and internalId of the current record.
Script:
function beforeLoad(type,form)
{
var newId = nlapiGetRecordId();
var newType = nlapiGetRecordType();
nlapiLogExecution(´DEBUG´,´<Before Load Script> type:´+type+´, RecordType: ´+newType+´, Id:´+newId);
}f
unction beforeSubmit(type)
{
var newId = nlapiGetRecordId();
var newType = nlapiGetRecordType();
nlapiLogExecution(´DEBUG´,´<Before Submit Script> type:´+type+´, RecordType: ´+newType+´, Id:´+newId);
}f
unction afterSubmit(type)
{
var newId = nlapiGetRecordId();
var newType = nlapiGetRecordType();
nlapiLogExecution(´DEBUG´,´<After Submit Script> type:´+type+´, RecordType: ´+newType+´, Id:´+newId);
}
User event scripts are executed on the NetSuite server. They are executed when users perform certain actions on records, such as create, load, update, copy, delete, or submit. Most standard NetSuite records and custom record types support user event scripts.
Note:
-------------------
User event scripts cannot be triggered to run by other user event scripts. You can, however, execute a user event script from a call within a scheduled, portlet, or Suitelet script.
With user event scripts you can do such things as:
1. Implement custom validation on records
2. Enforce user-defined data integrity and business rules
3. Perform user-defined permission checking and record restrictions
4. Implement real-time data synchronization
5. Define custom workflows (redirection and follow-up actions)
6. Implement custom form customizations
For complete guide of suitescript visit:
Complete SuiteScript Guide(Tutorial)- Click Here
Reference: system.netsuite.com