Microsoft Office Online
Sign in to My Office Online (What's this?) | Sign in

 
 
Microsoft Office Groove
Search
Search
 
Icon: Flag: (c) Microsoft
Get up to speed
 
 
 
Product Information
Help and How-to
Related Products and Technologies
Support and Feedback
Technical Resources
Additional Resources
Warning: You are viewing this page with an unsupported Web browser. This Web site works best with Microsoft Internet Explorer 6.0 or later, Firefox 1.5, or Netscape Navigator 8.0 or later. Learn more about supported browsers.

Adding scripts to a custom tool
 

In custom tools developed in the Forms tool, you can add script code to forms. These scripts are executed when the user is accessing the form. Scripts make it possible for you to extend the capabilities of the Forms tool to handle specialized application requirements. In custom tools developed in the InfoPath Forms tool, scripts are added to forms in Microsoft InfoPath.

What do you want to do?


Learning more about form scripts

In addition to standard HTML DOM script programming, form scripts can do the following:

  • Execute on special Groove events, such as form initialization and submitting new or updated data.
  • Access Groove services to get context information such as discovering the members of the workspace or to perform operations, such as sending an instant message.
  • Access data in the underlying Forms tool record.
  • Perform lookups on data in the current tool or in other custom tools in the same or other workspaces.
  • Define a function that is executed to provide an initial value for a field.

To provide a function for a standard DOM event, name the function with the field name followed by an _ (underscore) and the event name. For example, if you have a field named Category, you could define Category_OnFocus, Category_OnClick, and Category_OnChange functions.

When accessing the form, you can use the name GrooveFormBase. For example, in JavaScript the following are equivalent; both return the value of the PhoneNumber field:

document.forms[0].PhoneNumber.value

document.GrooveFormBase.PhoneNumber.value

If you want to examine the html source of the form, click on the HTML Source tab in the Forms Designer Preview window. This may be useful in coding or debugging scripts that handle DOM events or that dynamically update the form.

You can also define functions that are executed before or after the following events:

  • Initialize: when a form is first displayed to the user.
  • Terminate: when a form is about to close.
  • Print: when the user is printing a single form (but not when the user is printing records from a view).
  • SubmitData: when the user has added a new record or updated an existing one.
  • PropagateUpdates: before and after inherited fields are updated in child records after the update has been submitted for the parent record.

In the script code, access to the Forms tool record is provided by the GetFormRecord global variable. You can use the record to read or set the record's fields or to get the parent record. Access to the Forms tool services is provided through the UIDelegate object returned by the GetApp() global function. These and other additional context information is provided by the PublicFunctions.js script.

If you are accessing the Forms tool record in your script, you should do it in a Transaction and should code your script with exception handling. Consequently, scripts that access records should be implemented in JavaScript, which provides the Try-Catch exception handling statements.

Top of Page Top of Page

Adding a new script to a form

To add a new form script, do the following:

  1. Open the Designer.
  2. Select the form to which you want to add a form script.
  3. Click the Form Scripts tab.
  4. Click Add Script to open the Add Script dialog box.
  5.  Note    You can also open the Add Script dialog box by clicking Create New Script in the Design Object Pane. If you take this path, the scripts you add will not be assigned to a form until you edit a form later and select the script on the Form Scripts tab.

  6. Do one of the following in the Add Script dialog box:
    • Click New to open the Edit Script dialog box, name and enter the script in a selected language. If you want, click Create Lookup String to use lookup values in the script. Click OK when the script is ready.
    • Click Browse to browse for a script file to add from your file system, and click Open.
    • Click OK to add the script to the form.

Top of Page Top of Page

Editing a form script

To edit a form script, do the following:

  1. Open the Designer.
  2. Expand the Scripts section and select the script you want to modify.
  3. Edit the script as needed.
  4. Click OK.

Top of Page Top of Page

Deleting a form script

To delete a form script, do the following:

  1. Open the Designer.
  2. Expand the Scripts section.
  3. Right-click the script you want to delete and select Delete.
  4. Click Yes at the confirmation prompt.

Top of Page Top of Page

advertisement