how can i have a script run after the record is sa...
# suitescript
s
how can i have a script run after the record is saved
s
would this work i am trying to create a save print and print label button
b
this is how you would add buttons that run scripts
but i would not recommend this task to someone who didnt immediately know to use user event scripts
s
i have a button that currently prints the label and packing slip i want it to run when the user hits save
b
thats actually going to be the difficult part
suitescript offers nothing to do the record save
you would have to do that part in javascript
s
javascript is fine also
b
after the record is saved, in the afterSubmit event, you can redirect to the url you use for printing
s
does the after submit stil have accses /scope to run this
Copy code
function printMeNow() {
    var id = nlapiGetRecordId();
    show_preview(document.forms['main_form'].orderid.value, id);
    //print_shipping_label(document.forms['main_form'].orderid.value, id) //Standard Print Button on Item Fulfillment
    // print_shipping_label(document.forms['main_form'].orderid.value, id); //Standard Print Label Button on Item Fulfillment
    setTimeout(function () {
        
        print_shipping_label(document.forms['main_form'].orderid.value, id)
        alert
    }, 15000);
  
}
b
keep in mind that your button will probably have to set a field on the transaction so that your script can tell that the button was pressed
again, my warning is that you are doing something that is beyond what I would consider easily maintained suitescript
its a bad idea to learn what you shouldnt do before you learn what you should do
that said, there is nothing in suitescript that will save the current record for you
you would have to use javascript to submit the form
after the form is submitted, you should redirect to the url used for printing
theoretically you can use your button you added by taking advantage that netsuite normally redirects you back to the transaction in view mode after the transaction is saved
s
thanks
b
that would be done by adding a client script in the beforeLoad using Form.clientScriptModulePath