Most common API used in client side script

There are two object which been used very frequently at client side.

    1. g_form
    2. g_user

The GlideForm client-side API provides methods for managing form and form fields like:

    • Retrieve a field value on a form
    • Hide a field
    • Make a field read-only
    • Write a message on a form or a field
    • Add fields to a choice list
    • Remove fields from a choice list
For Live Demonstration you can watch this video.

Most commonly used GlideForm(g_form) methods are:

    • getValue()
    • addOption()
    • clearOptions()
    • addInfoMessage()
    • addErrorMessage()
    • showFieldMsg()
    • clearMessages()
    • getSections()
    • getSectionName()

 

The GlideUser API provides methods and non-method properties for finding information about the currently logged in user and their roles.

The GlideUser API has properties and methods to retrieve the user’s:

    • First name
    • Full name
    • Last name
    • User ID
    • User name

The GlideUser API also has methods for determining if a user has a specific role.

function onLoad() {
   //Type '' appropriate comment here, and begin script below
    g_form.showErrorBox('assigned_to', 'Info message');
    alert(g_form.getValue('short_description'));
    g_form.addInfoMessage('Testing');
    g_form.addErrorMessage('Testing2');
    g_form.showFieldMsg('assigned_to', 'Info message');
    confirm('Hi');
    g_form.getSections()[1].hide(); 
    
    alert(g_user.hasRole('itil'));
    alert(g_user.hasRoleExactly('itil'));
    
    
    
}

 

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here