Difference between revisions of "How to Script Buttons"
m (Reverted edits by Agegeleruvy (Talk); changed back to last version by BrianM) |
|||
| (9 intermediate revisions by 4 users not shown) | |||
| Line 1: | Line 1: | ||
| + | __NOTOC__ | ||
| + | {{Global Header}} | ||
| + | {{Global Announcement}} | ||
| + | |||
| + | == Overview == | ||
Service Desk buttons are created using a ImgBtnCreate function. | Service Desk buttons are created using a ImgBtnCreate function. | ||
| Line 45: | Line 50: | ||
|- | |- | ||
|} | |} | ||
| − | |||
== More Examples == | == More Examples == | ||
| − | |||
'''Open a Service Desk htmpl file in a new window''' | '''Open a Service Desk htmpl file in a new window''' | ||
<source lang="javascript">ImgBtnCreate("btn001", "Custom Form", "popup_window('','ztest.htmpl'))", true, 0, "Select this button to view a Service Desk htmpl in a new window");</source> | <source lang="javascript">ImgBtnCreate("btn001", "Custom Form", "popup_window('','ztest.htmpl'))", true, 0, "Select this button to view a Service Desk htmpl in a new window");</source> | ||
| − | |||
'''Open a Service Desk htmpl file in an existing window''' | '''Open a Service Desk htmpl file in an existing window''' | ||
<source lang="javascript">ImgBtnCreate("btn001", "Existing Window", "upd_frame('ztest.htmpl')", true, 0, "Select this button to use the existing window");</source> | <source lang="javascript">ImgBtnCreate("btn001", "Existing Window", "upd_frame('ztest.htmpl')", true, 0, "Select this button to use the existing window");</source> | ||
| − | |||
'''Open a new window referencing an external URL''' | '''Open a new window referencing an external URL''' | ||
| − | <source lang="javascript">ImgBtnCreate("btn001", "SDU", " | + | <source lang="javascript">ImgBtnCreate("btn001", "SDU", "popupWithURL('http://www.servicedeskusers.com', 1, 1, '')", true, 0, "User Community for CA/Unicenter Service Desk");</source> |
| − | + | ||
'''Open a new email message referencing the ticket''' | '''Open a new email message referencing the ticket''' | ||
<source lang="javascript">ImgBtnCreate("btn001", "Send eMail", "window.open('mailto:?subject=Regarding $args.type.sym $args.ref_num&body=Click on the following URL to view $args.type.sym $args.ref_num: $args.web_url')", true, 0);</source> | <source lang="javascript">ImgBtnCreate("btn001", "Send eMail", "window.open('mailto:?subject=Regarding $args.type.sym $args.ref_num&body=Click on the following URL to view $args.type.sym $args.ref_num: $args.web_url')", true, 0);</source> | ||
| − | + | '''Launch an application''' | |
| − | + | <source lang="javascript">function ExecuteMyApp() { | |
| − | + | var myshell = new ActiveXObject( "WScript.shell" ); | |
| − | + | myshell.run( 'enter application command line here', 1, true ); | |
| − | + | } | |
| − | + | ImgBtnCreate("btn001", "My Application", "ExecuteMyApp()", true, 0, "Click this button to launch My Application");</source> | |
| − | + | ||
Latest revision as of 05:25, 30 November 2010
To discuss or ask questions about this article, select the discussion tab above.
Overview
Service Desk buttons are created using a ImgBtnCreate function.
ImgBtnCreate(btnID, btnCaption, func, btnEnabled, btnWidth, help, tabIndex)
| Attribute | Description | Examples |
|---|---|---|
| btnID | Used for referencing the button. This is typically a label used for easy identification of the button in scripts. | <source lang="javascript">ImgBtnCreate("btn001", ...
ImgBtnCreate("btnchg", ... ImgBtnCreate("mybtn", ...</source> |
| btnCaption | The text to be displayed on the button. Either identify the string such as "My Button" or reference a msgtext() value. The msgtext() value is obtained from the msg_cat.js file. | <source lang="javascript">ImgBtnCreate(..., "I am a button"...
ImgBtnCreate(..., msgtext(514), ...</source> |
| func | The script to be initiated when the button is selection | <source lang="javascript">ImgBtnCreate(..., ..., "detailSave('NEW_CHANGE')", ...
ImgBtnCreate(..., ..., "myscript()", ...</source> |
| btnEnabled | If true then the button is Active. If false then it is not. | <source lang="javascript">ImgBtnCreate(..., ..., ..., true, ...
ImgBtnCreate(..., ..., ..., false, ...</source> |
| btnWidth | Button width in pixels. 0 defaults to the size of the text. | <source lang="javascript">ImgBtnCreate(..., ..., ..., ..., 0, ...
ImgBtnCreate(..., ..., ..., ..., 220, ...</source> |
| help | Displays information in status bar of the browser window. This is typically the bottom left-hand corner of your. | <source lang="javascript">ImgBtnCreate(..., ..., ..., ..., ..., "Click here to open a ticket", ...</source> |
| tabIndex |
More Examples
Open a Service Desk htmpl file in a new window <source lang="javascript">ImgBtnCreate("btn001", "Custom Form", "popup_window(,'ztest.htmpl'))", true, 0, "Select this button to view a Service Desk htmpl in a new window");</source>
Open a Service Desk htmpl file in an existing window <source lang="javascript">ImgBtnCreate("btn001", "Existing Window", "upd_frame('ztest.htmpl')", true, 0, "Select this button to use the existing window");</source>
Open a new window referencing an external URL <source lang="javascript">ImgBtnCreate("btn001", "SDU", "popupWithURL('http://www.servicedeskusers.com', 1, 1, )", true, 0, "User Community for CA/Unicenter Service Desk");</source>
Open a new email message referencing the ticket <source lang="javascript">ImgBtnCreate("btn001", "Send eMail", "window.open('mailto:?subject=Regarding $args.type.sym $args.ref_num&body=Click on the following URL to view $args.type.sym $args.ref_num: $args.web_url')", true, 0);</source>
Launch an application <source lang="javascript">function ExecuteMyApp() { var myshell = new ActiveXObject( "WScript.shell" ); myshell.run( 'enter application command line here', 1, true ); } ImgBtnCreate("btn001", "My Application", "ExecuteMyApp()", true, 0, "Click this button to launch My Application");</source>