Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Section
Column

You can add custom behaviors by adding JavaScript to your form/flow. For example, you may want to change the look of your form's submit button when the user hovers the mouse over the button. It is possible to associate a custom JavaScript handler to any form control.  See Custom JavaScript Examples for sample code.

Warning

Although JavaScript will accomplish the task, it is important to note that your scripts are not subjected to formal testing by the frevvo quality assurance team. Choosing an approach that is part of the product like Business Rules is a better choice than adding JavaScript since released versions undergo rigorous quality assurance testing. Customizations using JavaScript should only be used under special situations and if there is no other way to customize the form to the requirements.

For example, let's say you have a message control in your form that contains markup to pull a custom JavaScript. The URL for the script contains the home directory and revision number - (http://localhost:8080/frevvo/js-24487/libs/script.js).  An upgrade of  to new release or revision version could potentially stop the form from working.

If you choose to add JavaScript, we strongly recommend that you are familiar with a JavaScript debugger / web development tool such as the Firebug extension for Firefox.

Column
width300px

On this page:

Table of Contents
maxLevel2

...

    1. If a designer uploads a custom.js file to an application, it is only available for forms/flows in that application. Refer to  Method 1a below for the details.
    2. If a superuser/tenant admin uploads custom.js to the tenant, then the custom.js will be available to all forms/flows in the tenant. Refer to Method 1b below for the details

...

Method 1a - Upload custom JavaScript to an Application

Upload your custom JavaScript to  via the Scripts tab on the left menu inside your application.

Follow these steps:

Your custom JavaScript must contain the comment // frevvo custom JavaScript as the first line of the file or the upload will not be successful. Note the CustomEventHandlers JavaScript object. Application level custom js requires that you create a JavaScript object called CustomEventHandlers.

...

Browse your hard drive for your script file, Click Upload. Your file will be uploaded and it will display with the name Custom Script even though your script file may have another name.

Warning

Be Aware that existing JavaScript files will be overwritten. Download the existing custom.js file, append your new code to existing code then upload the combined file if you want to preserve the existing JavaScript

...

If you need to modify the script, you must download it, make your modifications and then upload it again. When you download the script by clicking on the  Image Removed Download icon, it will be named custom.js.  

Once you have uploaded the JavaScript, it is available for all forms/flows in the application. Remember to add the CSS class name to your form controls or your JavaScript may not work.

...

Method 1b - Upload custom JavaScript to a Tenant

The  superuser/ tenant admin can upload custom JavaScript to the tenant. Custom JavaScript uploaded on the tenant level is available to all designer users in the tenant. Let's say you are the tenant admin and you have written custom JavaScript to include custom fonts in Message controls or format SSN fields that you want to make available to all designers in your tenant . Upload your custom JavaScript to your tenant via the Scripts link on the Manage Tenants page.

Follow these steps:

Your custom JavaScript must contain the comment // frevvo custom JavaScript as the first line of the file or the upload will not be successful. Note the TenantEventHandlers JavaScript object. Tenant level custom js requires that you create a JavaScript object called TenantCustomEventHandlers.

...

 

...

Browse your hard drive for you script file, Click Upload. Your file will be uploaded and it will display with the name Custom Script even though your script file may have another name.

Warning

Be Aware that existing JavaScript files will be overwritten. Download the existing custom.js file, append your new code to existing code then upload the combined file if you want to preserve the existing JavaScript

...

If you need to modify the script, you must download it, make your modifications and then upload it again. When you download the script by clicking on the  Image Removed Download icon, it will be named tenantcustom.js.  

Once you have uploaded the JavaScript, it is available for all designers in your tenant to use in their forms/flows.Remember to add the CSS class name to your form controls or your JavaScript may not work.

...

Tip
  • If your JavaScript does not behave as expected after upgrading your version of , it may be caused by a scrubbing of the custom.js file content by XSS protection. You may notice that all your code is on a single commented out line upon Inspection of the custom.js file, Upload an "unsrubbed" version of your custom.js file to solve the issue.
  • f you upload a custom.js file to the Tenant Level and the event handler is named CustomEvenHandlers not TenantCustomEventHandlers you will not see an error message. The function may operate correctly but you may notice a delay in loading the form/flow in Use mode.

What if I upload different custom JavaScripts to an application and the tenant?

If you upload custom JavaScript to the tenant and then upload a different custom.js file to an application, will load both files. The functionality of both scripts will be available to a designer creating forms/flows in the application. For example, let's say you upload custom JavaScript to change the first letter of each word typed into a field to upper case.The class name is CorrectCase. You upload your custom JavaScript to the tenant.

...

titleClick here for an example of the Correct Case JavaScript

...

    1. .
Note

Custom.js scripts can be uploaded at two levels in :

  • Application level (i.e. inside an open application) -  At the application level, you must use the CustomEventHandlers JavaScript object.  
  • Tenant level - The custom.js can only be uploaded to the tenant level by the tenant administrator.  At the tenant level, the custom.js file must use the TenantCustomEventHandlers JavaScript object.  
  • If a custom.js file contains the wrong custom handler for the level you are uploading it to, you may see a delay in loading and the custom.js will not work. Verify that the CustomEventHandler is correct.


Method 2
-  Add a Message Control that contains your JavaScript. Refer to  Method 2 below for the details.

Method 1a - Upload custom JavaScript to an Application

Upload your custom JavaScript to  via the Scripts tab on the left menu inside your application.

Follow these steps:

  1. Your custom JavaScript must contain the comment // frevvo custom JavaScript as the first line of the file or the upload will not be successful. Note the CustomEventHandlers JavaScript object. Application level custom js requires that you create a JavaScript object called CustomEventHandlers.

    Here is an example of code that will add dashes to a Social Security number control as the user is typing it in. See Custom JavaScript Examples for information on this sample code. Notice the JavaScript comment is the first line in the script file.

    Image Added

  2. Login to  as a designer user. Click the Image AddedEdit icon for the application where you want to use the JavaScript. Click on the Script tab located on the left menu.

    Image Added

  3. Browse your hard drive for your script file, Click Upload. Your file will be uploaded and it will display with the name Custom Script even though your script file may have another name.

    Warning

    Be Aware that existing JavaScript files will be overwritten. Download the existing custom.js file, append your new code to existing code then upload the combined file if you want to preserve the existing JavaScript


  4. If you need to modify the script, you must download it, make your modifications and then upload it again. When you download the script by clicking on the  Image Added Download icon, it will be named custom.js.  

  5. Once you have uploaded the JavaScript, it is available for all forms/flows in the application. Remember to add the CSS class name to your form controls or your JavaScript may not work.

    Here is an image of an Employee Information form using uploaded JavaScript to enter dashes in the Social Security Number field while the user is entering the data.

    Image Added

Method 1b - Upload custom JavaScript to a Tenant

The  superuser/ tenant admin can upload custom JavaScript to the tenant. Custom JavaScript uploaded on the tenant level is available to all designer users in the tenant. Let's say you are the tenant admin and you have written custom JavaScript to include custom fonts in Message controls or format SSN fields that you want to make available to all designers in your tenant . Upload your custom JavaScript to your tenant via the Scripts link on the Manage Tenants page.

Follow these steps:

  1. Your custom JavaScript must contain the comment // frevvo custom JavaScript as the first line of the file or the upload will not be successful. Note the TenantEventHandlers JavaScript object. Tenant level custom js requires that you create a JavaScript object called TenantCustomEventHandlers.

    Here is an example of code that will add dashes to a Social Security number control as the user is typing it in. See Custom JavaScript Examples for information on this sample code. Notice the JavaScript comment is the first line in the script file.

    Image Added

     

  2. Login to  as a superuser/tenant admin. Navigate to the Manage Tenant screen. Click the Manage Script link.

    Image Added

  3. Browse your hard drive for you script file, Click Upload. Your file will be uploaded and it will display with the name Custom Script even though your script file may have another name.

    Warning

    Be Aware that existing JavaScript files will be overwritten. Download the existing custom.js file, append your new code to existing code then upload the combined file if you want to preserve the existing JavaScript


  4. If you need to modify the script, you must download it, make your modifications and then upload it again. When you download the script by clicking on the  Image Added Download icon, it will be named tenantcustom.js.  

  5. Once you have uploaded the JavaScript, it is available for all designers in your tenant to use in their forms/flows.Remember to add the CSS class name to your form controls or your JavaScript may not work.

    Here is an image of an Employee Information form using uploaded JavaScript to enter dashes in the Social Security Number field while the user is entering the data.

    Image Added

Tip
  • If your JavaScript does not behave as expected after upgrading your version of , it may be caused by a scrubbing of the custom.js file content by XSS protection. You may notice that all your code is on a single commented out line upon Inspection of the custom.js file, Upload an "unsrubbed" version of your custom.js file to solve the issue.
  • f you upload a custom.js file to the Tenant Level and the event handler is named CustomEvenHandlers not TenantCustomEventHandlers you will not see an error message. The function may operate correctly but you may notice a delay in loading the form/flow in Use mode.

What if I upload different custom JavaScripts to an application and the tenant?

If you upload custom JavaScript to the tenant and then upload a different custom.js file to an application, will load both files. The functionality of both scripts will be available to a designer creating forms/flows in the application. For example, let's say you upload custom JavaScript to change the first letter of each word typed into a field to upper case.The class name is CorrectCase. You upload your custom JavaScript to the tenant.

Expand
titleClick here for an example of the Correct Case JavaScript
Code Block
// frevvo custom JavaScript
var TenantCustomEventHandlers = {
   setup: function (el) {
       if (CustomView.hasClass(el, 'CorrectCase')) {
           FEvent.observe(el, 'input', this.doCorrectCase.bindAsObserver(this, el));
       }
   },
   doCorrectCase: function (event, element) {
       var val = element.value;
       var str = val.toLowerCase();
       var spl = str.split(" ");
       var upstring = "";
       for (var i = 0; i < spl.length; i++) {
           try { //onkeypress will cause an error on first keypress
               upstring += spl[i][0].toUpperCase();
 {
         } catch (err)try {} //onkeypress will cause an error on first  keypress
  upstring += spl[i].substring(1, spl[i].length);            upstring += " "spl[i][0].toUpperCase();
       }        element.value = upstring.substring(0, upstring.length - 1);} catch (err) {}
     } }

You create another custom script to add the dashes to the Social Security Number as the user is typing. The class name is SSN1. You upload this custom script to an application.

Expand
titleClick here for an example of the JavaScript to add dashes to the SSN
Code Block
// frevvo custom JavaScript var CustomEventHandlersupstring += {
  spl[i].substring(1, spl[i].length);
  setup: function (el) {      upstring += " if (CustomView.hasClass(el, 'SSN1')) {";
       }
       FEvent.observe(el, 'keydown', this.formatSSN.bindAsObserver(this, el));
       element.value = upstring.substring(0, upstring.length - 1);
    FEvent.observe(el, 'keyup', this.formatSSN.bindAsObserver(this, el));
  }
}

You create another custom script to add the dashes to the Social Security Number as the user is typing. The class name is SSN1. You upload this custom script to an application.

Expand
titleClick here for an example of the JavaScript to add dashes to the SSN
Code Block
// frevvo custom JavaScript
var CustomEventHandlers = {
    setup: }function (el) {
  },     formatSSN: functionif (CustomView.hasClass(eventel, element'SSN1')) {
        if  (event.keyCode != 46 && event.keyCode != 8) { FEvent.observe(el, 'keydown', this.formatSSN.bindAsObserver(this, el));
             fldVal = element.valueFEvent.observe(el, 'keyup', this.formatSSN.bindAsObserver(this, el));
        }
    var},
nom = fldVal.charAt(fldVal.length - 1);formatSSN: function (event, element) {
        if (isNaN(nom)event.keyCode != 46 && nomevent.keyCode != "-"8) {
            fldVal =   element.value = fldVal.substring(0, fldVal.length - 1);
            }var elsenom {
  = fldVal.charAt(fldVal.length - 1);
             if ((fldVal.length == 3) || (fldVal.length == 6)) {
   isNaN(nom) && nom != "-") {
                element.value = fldVal + "-".substring(0, fldVal.length - 1);
            } else   }{
                if ((fldVal.length >== 123) {
                    element.value = fldVal.substring(0, || (fldVal.length -== 16)); {
               }             }element.value = fldVal + "-";
         }     }
}

...

Uploading custom.js files with the same class name on the application and tenant levels

Uploading custom.js files with the same class name on the application and tenant levels is not recommended. This could result in unpredictable behavior. When two custom event handlers are bound to the same event (tenant level and app level), there is no guarantee which handler is called first. This is under the control of the JavaScript engine. Rewrite your JavaScript to avoid this situation.

Image Removed

Incorrect CustomEvantHandler in Custom JavaScript

Custom.js scripts can be uploaded at two levels in :

...

  }
                if (fldVal.length >= 12) {
                    element.value = fldVal.substring(0, fldVal.length - 1);
                }
            }
        }
    }
}

A designer creating forms/flows in the application will have access to both custom scripts. Both scripts will function properly.

Image Added

Uploading custom.js files with the same class name on the application and tenant levels

Uploading custom.js files with the same class name on the application and tenant levels is not recommended. This could result in unpredictable behavior. When two custom event handlers are bound to the same event (tenant level and app level), there is no guarantee which handler is called first. This is under the control of the JavaScript engine. Rewrite your JavaScript to avoid this situation.

Image Added

Method 2

Follow these steps to add JavaScript to your form using the Message control:

...