TMACUL

http://www.servicedeskusers.com/How_to_Script_Buttons

Blog Post created by TMACUL Champion on Jan 1, 2016

How to Script Buttons

 

From SDU

Jump to: navigation, search

 

To make corrections or additions to this article, select the edit tab above.
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)

 

AttributeDescriptionExamples
btnIDUsed for referencing the button. This is typically a label used for easy identification of the button in scripts.
ImgBtnCreate("btn001", ... ImgBtnCreate("btnchg", ... ImgBtnCreate("mybtn", ...
btnCaptionThe 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.
ImgBtnCreate(..., "I am a button"... ImgBtnCreate(..., msgtext(514), ...
funcThe script to be initiated when the button is selection
ImgBtnCreate(..., ..., "detailSave('NEW_CHANGE')", ... ImgBtnCreate(..., ..., "myscript()", ...
btnEnabledIf true then the button is Active. If false then it is not.
ImgBtnCreate(..., ..., ..., true, ... ImgBtnCreate(..., ..., ..., false, ...
btnWidthButton width in pixels. 0 defaults to the size of the text.
ImgBtnCreate(..., ..., ..., ..., 0, ... ImgBtnCreate(..., ..., ..., ..., 220, ...
helpDisplays information in status bar of the browser window. This is typically the bottom left-hand corner of your.
ImgBtnCreate(..., ..., ..., ..., ..., "Click here to open a ticket", ...
tabIndex

More Examples

Open a Service Desk htmpl file in a new window

ImgBtnCreate("btn001", "Custom Form", "popup_window('','ztest.htmpl'))", true, 0, "Select this button to view a Service Desk htmpl in a new window");

Open a Service Desk htmpl file in an existing window

ImgBtnCreate("btn001", "Existing Window", "upd_frame('ztest.htmpl')", true, 0, "Select this button to use the existing window");

Open a new window referencing an external URL

ImgBtnCreate("btn001", "SDU", "popupWithURL('http://www.servicedeskusers.com', 1, 1, '')", true, 0, "User Community for CA/Unicenter Service Desk");

Open a new email message referencing the ticket

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);

Launch an application

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");

Retrieved from "http://www.servicedeskusers.com/How_to_Script_Buttons"

Outcomes