Reputation: 707
I need to add a button to my sales order form where when you click the button it will trigger a script I created. Basically the button calculates and fills in fields based on what you put for earlier fields. Could I add a button through a workflow and link this script through the add button option?
I also have no clue how to test this out on the sales order form I'm not even sure it works. Any advice would be great, thanks
Upvotes: 1
Views: 5333
Reputation: 2840
You can add a button using a Before Load using event. You can also 'attach' a undeployed client side script during this event.
You client side script will contain the logic you need when the button is clicked.
You code will be like this:
function beforeLoad_addButton(type, form) {
form.setScript('customscript_so_logic'); // This should be the script id of your undeployed client side script
form.addButton('custpage_custom_button', 'Custom Button', logicFunction); // logicFunction should be a function in your JS file.
}
Basically when the user clicks on your Custom Button, it will execute the logic found in 'logicFunction'
Upvotes: 1