Creating a Button That Displays on an SCM Form in Workbench
search cancel

Creating a Button That Displays on an SCM Form in Workbench

book

Article ID: 50599

calendar_today

Updated On:

Products

CA Harvest Software Change Manager - OpenMake Meister CA Harvest Software Change Manager

Issue/Introduction

Of the types of objects available to be placed on a SCM form, the "button" object is not available.  How can we add a button to a form?

Environment

Harvest Software Change Manager v12.x and higher

Resolution

Create your custom form type normally, using the instructions found in the Harvest documentation here: Create and Modify Form Types

Once the xml file for your form has been created, you can edit the xml file and

  1. Add a "button" tag in the appropriate place on the form, like this:
    <button id="button1" label = "button1"/>
  2. Add an "events" tag in the Javascript area of the form's xml, like this:
    <events language="javascript" client="eclipse"> 
    function button1Clicked(){
    var file1 = editor.getTextFieldValue("hodproject");
    var app1 = "notepad.exe";
    java.lang.Runtime.getRuntime().exec(app1 + " " + file1);
    }
    </events>

Here is an example form's xml file:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!DOCTYPE harvest_form SYSTEM "harwebForms.dtd">
<harvest_form dbtable="buttontest" id="buttontest" name="Testing A Button" numtabs="0">

<events language="javascript" client="eclipse">
function button1Clicked(){
  var file1 = "C:\\Temp\\README.TXT";
  var app1 = "notepad.exe";
  java.lang.Runtime.getRuntime().exec(app1 + " " + file1);}
</events>

  <text-field cols="80" dbfield="formname" id="formname" label="Form Name" maxsize="128"/>

  <text bold="false" italics="false" size="5" value="This form tests a button"/>
  
  <button id="button1" label = "button1"/>

</harvest_form>


Once your form's xml is updated, use the hformsync command to upload it to the Harvest database.  Once this is successfully completed, when you open your form, you will now see a button: