LinkedIn
Copied!

Table of Contents

Changing global harness behavior with JavaScript

Version:

Only available versions of this content are shown in the dropdown
Applicable to Theme Cosmos applications

Customize all harnesses in your application by modifying the default JavaScript code.

For global changes in your application, you can include the customized scripts in the UserWorkForm HTML fragment rule, which is called during the loading of a harness.

Create custom JavaScript code that you can use later to override the code in some of the Pega Platform rules.
  1. In the header of Dev Studio, in the Search field, search for and open the UserWorkForm HTML fragment rule.

  2. Click Save As.

  3. On the New tab, in the Context section, specify the context of the fragment rule:

    1. In the Development branch list, select the branch.

    2. Select the check box with your application name.

    3. In the Add to ruleset list, select the ruleset that is specific to your application.

    Do not change the name of the fragment rule.
  4. Click Create and open.

    The HTML fragment rule is now available to the application ruleset.
  5. On the HTML tab, in the text field, enter your custom JavaScript code.

    To change the default busy indicator image, perform the following actions:
    1. Create a binary file with your custom image.
    2. On the HTML tab of the UserWorkForm HTML fragment rule, in the text field, add the following snippet in HTML Source:
    <script>
       pega.ui.busyIndicator.prototype.createIndicatorImage = function() {
       if(this.oSpan == null)
       this.initialize(this._sNode);
       var oSpan = this.oSpan;
       if (this._message && this._message.length > 0) oSpan.innerHTML = "<img src = 'webwb/CustomPreloader.gif'   alt='loading' />" + " " + this._message ;
       else oSpan.innerHTML = "<img src = 'webwb/CustomPreloader.gif' alt='loading' />";
       }
    </script>
  6. In the upper-right corner of the screen, click Save.

    All of the harnesses of your application now include the custom script, which runs whenever a harness is loaded.
Did you find this content helpful?

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.