Thank you for your feedback.
Form temporarily unavailable. Please try again or contact to submit your comments.

Client script FAQ

Log in to subscribe to topics and get notified when content changes.

Client script FAQ

Frequently asked questions and answers regarding client scripting.

Why do I have to name scripts like that?

The client code needs to know which function to attach to the document. Hence, it requires that you follow our naming convention with functions. Note that you can have more than one function on a client side script and have your onSubmit() function, for example, call other functions. The requirement is that the primary function follow our naming convention.

Can I have more than one function listening to the same thing?

You can, but there is no guarantee of sequencing. You cannot predict what order your event handlers will run.

How do I reference a field on the form?

To reference the actual HTML element of the priority field on the incident form:
var priority_field = g_form.getControl('priority');
The easiest way to reference a field's value is to use the built-in g_form() helper variable:
var value_of_priority = g_form.getValue('priority');

How do I cancel a form submission?

Have your onSubmit() function return false. For example the following snippet of code disallows all form submission.
function onSubmit() { return false; }
How do I confirm a field value with the user?
function onSubmit() { //This allows you to access fields from the referenced record 
  var assignedTo = g_form.getReference('assigned_to');
  var answer = confirm("The Assigned to is " + assignedTo.user_name + ". Is this correct?");
  if(answer == true) { return false ; } }

How do I force a Save and Stay?

// onChange event on Incident table using Field name "Caller" 
function onChange(control,oldValue,newValue,isLoading) { 
// Setting the control value prevents against an infinite loop  
// Change caller_id to the field the change event reacts to 

  if(control.caller_id != newValue && control.caller_id != null) { 
    //do any comparisons you want
    // // . . . //
    //does an update and stay
    gsftSubmit(document.getElementById('sysverb_update_and_stay')); }

 // Change caller_id to the field the change event reacts to 
  control.caller_id = newValue; }

How do I call a business rule from a client script?

To call a business rule from a client script, use GlideAjax().