FUNCTION
= mandatory for each custom button script
For each custom button, a FUNCTION must be specified. The FUNCTION is the connection to the script written in the Script Editor and it is this parameter that defines what actually should happen when the end-user clicks the button.
The application also supports four standards scripts which can be connected to a ribbon custom button and selected in the FUNCTION field. For more information, see Standard Scripts. If a standard script is selected as function, then no template script needs to be linked to the actual template.
When adding a new custom button or editing an existing one in Template Design, a function always needs to be linked to the button. It is the function selected that actually decides what kind of action should be executed when the user selects the ribbon button.
The four standard scripts always display in the Function drop-down when adding a button in a form. These four standard scripts are form specific scripts, so they will not be visible when adding a button in a report.
If a template script is also linked to the template, then the Function drop-down will also contain all public methods returned by the template script.
Note: Only public methods without any arguments will be visible in the Function drop-down in Custom Buttons. Script functions that require input variables are not supported in a custom button, and therefore, will not be visible in the Function drop-down.
Link the custom button to the function you want to be executed when the user clicks the ribbon button:
When the right panel is collapsed, the information added in the above dialog will be automatically written to the SCRIPTS worksheet and the FUNCTION property for the specific button:
Note: If the function defined for a button is a method from a linked template script (not a standard script), then you need to ensure that the script containing that function is connected to the template. The function name in the SCRIPTS worksheet must be exactly the same as the function name in the linked script. If you have created a custom button towards a script function and for some reason the script connection is removed from the template, then the button will not work and return an error.
Function in the script (Script Editor):