AgileApps Support Wiki Pre Release

HowTo:Add a Custom Print Button to a Form

From AgileApps Support Wiki
Revision as of 19:30, 1 February 2012 by imported>Aeric (Created page with "This code adds a '''[Custom Print]''' button to a Form, when placed in an On Load Form Script. In this case, the goal is to restrict a user who has access to that form to…")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This code adds a [Custom Print] button to a Form, when placed in an On Load Form Script. In this case, the goal is to restrict a user who has access to that form to a specific template. (The standard Print operation makes all templates available. A standard Action button, meanwhile, is present in every form. This code puts the button in a specific form, to restrict template access for users whose role causes it to be displayed.)

<syntaxhighlight lang="javascript" enclose="div">

$("#print_button").remove(); $("#edit_button").parent().append( "<input type='button' id='customPrint' value='Custom Print' class='lj-button fg-button ui-state-default ui-corner-all' onClick=\"javascript:lj_printRecord('default_print_layout=template&show_print_layout=no&default_print_document=jsp&default_page_orientation=landscape&default_pdf=yes&show_pdf=no&print_immediately=yes');\">" ); </syntaxhighlight>

How it Works
$("#print_button").remove()
Remove the standard print button
$("#edit_button").parent().append
Finds the location of the edit button (present in every form), gets it's parent (the toolbar), and adds the new button to it.
class='lj-button fg-button ui-state-default ui-corner-all'
The standard CSS style elements for platform buttons.
<input type='button' ...
Define the button. (The entire string is one uninterrupted line.)
onClick=\"javascript:lj_printRecord(...
Specify the button's action


Learn more: JavaScript Functions#lj_printRecord