g_form is used very heavily all over in ServiceNow.
As such it has a lot of documented and undocumented functions.
Below I go over all of them and how to use them.

Property / Method CoreUI Mobile/SP/Workspaces Documented
activateTab Desktop No
addAttribute Desktop No
addDecoration Desktop Mobile Both
addErrorMessage Desktop Mobile Desktop
addGlideUIElement Desktop No
addInfoMessage Desktop Mobile Desktop
addNameMapEntry Desktop No
addOption Desktop Mobile Desktop
addSecurityReadOnlyFields Desktop No
addToCart Desktop No
addValidator Desktop No
addWarningMessage Desktop No
allChangedFieldsFilter Desktop No
changedFieldsFilter Desktop No
changeElementParent Desktop No
changeElementStyle Desktop No
clearMessages Desktop Mobile Desktop
clearOptions Desktop Mobile Desktop
clearValue Desktop Mobile Desktop
disable Desktop No
disableAttachments Desktop Desktop
enable Desktop No
enableAttachments Desktop Desktop
enableOption Desktop No
enableUIPolicyFields Desktop No
fieldChanged Desktop No
findV2RelatedListName Desktop No
flash Desktop Desktop
getAction Desktop No
getActionName Desktop Mobile Desktop
getBooleanValue Desktop Mobile Desktop
getControl Desktop Desktop
getControlByForm Desktop No
getDecimalValue Desktop Mobile Desktop
getDerivedFields Desktop No
getDisplayBox Desktop No
getDisplayValue Desktop Mobile No
getEditableFields Desktop No
getElement Desktop Desktop
getEncodedRecord Mobile No
getFieldNames Mobile No
getFormElement Desktop Desktop
getGlideUIElement Desktop No
getHelpTextControl Desktop Desktop
getIntValue Desktop Mobile Desktop
getLabel Desktop Mobile Mobile
getLabelOf Desktop Desktop
getMissingFields Desktop No
getNiBox Desktop No
getOption Desktop Desktop
getOptionControl Desktop No
orderNow Desktop No
getField Mobile No
getParameter Desktop No
getPrefixHandler Desktop No
getReference Desktop Mobile Desktop
getRelatedListNames Desktop Mobile No
getScope Desktop No
getSectionNames Desktop Mobile Desktop
getSections Desktop Desktop
getSysId Mobile No
getTableName Desktop Mobile Desktop
getTabNameForField Desktop No
getTitle Desktop No
getUniqueValue Desktop Mobile Desktop
getValue Desktop Mobile Desktop
getViewName Desktop Mobile No
hasAttribute Desktop No
hasField Desktop Mobile Both
hasFieldMsgs Desktop No
hideAllFieldMsgs Desktop Mobile Desktop
hideErrorBox Desktop Mobile Desktop
hideFieldMsg Desktop Mobile Desktop
hideRelatedList Desktop Mobile Desktop
hideRelatedLists Desktop Mobile Desktop
isDatabaseView Desktop No
isDisabled Desktop No
isDisplayNone Desktop No
isEditableField Desktop No
isInteger Desktop No
isLiveUpdating Desktop Desktop
isMandatory Desktop Mobile Desktop
isNewRecord Desktop Mobile Desktop
isNumeric Desktop No
isReadOnly Desktop Mobile No
isSectionVisible Desktop Desktop
isTemplateCompatible Desktop No
isUserPersonalizedField Desktop No
isVisible Desktop Mobile No
mandatoryCheck Desktop No
onSubmit Desktop No
registerHandler Desktop No
registerPrefixHandler Desktop No
removeAllDecorations Desktop No
removeContextItem Desktop No
removeCurrentPrefix Desktop No
refreshSlushbucket Desktop Desktop
removeDecoration Desktop Mobile Both
removeItem Desktop No
removeOption Desktop Mobile Desktop
resetPersonalizeHiddenFields Desktop No
resolveLabelNameMap Desktop No
resolveNameMap Desktop No
resolvePrettyNameMap Desktop No
save Desktop Mobile Desktop
serialize Desktop Mobile No
serializeChanged Desktop No
serializeChangedAll Desktop No
serializeTargetFields Desktop No
setAction Desktop No
setDisabled Desktop Mobile No
setDisabledControl Desktop No
setDisplay Desktop No
setFieldPlaceholder Mobile No
setLabel Mobile Mobile
setLabelOf Desktop Mobile Desktop
setLiveUpdating Desktop No
setMandatory Desktop Mobile Desktop
setMandatoryOnlyIfModified Desktop No
setReadOnly Desktop Mobile Desktop
setReadonly Desktop Mobile No
setRequiredChecked Desktop No
setScope Desktop No
setSectionDisplay Desktop Mobile No
setSensitiveDisplayValue Desktop No
setStreamJournalFieldsDisplay Desktop No
setTemplateValue Desktop No
setUserDisplay Desktop No
setValidation Desktop No
setValue Desktop Mobile Desktop
setVariablesReadOnly Desktop No
setVisible Desktop Mobile Desktop
showErrorBox Desktop Mobile Desktop
showFieldMsg Desktop Mobile Desktop
showRelatedList Desktop Mobile Desktop
showRelatedLists Desktop Mobile Desktop
submit Desktop Mobile Desktop
validate Desktop No

These methods I've found in the script that dictates it's available on
the portal/mobile clients.

Mobile addDecoration

Adds an icon on a field's label. This method is available starting with
the Fuji release. Icons available
here
Adding the same item twice is prevented; however, you can add the same
icon with a different title.

 g_form.addDecoration('caller_id', 'icon-star', 'VIP');

Mobile getLabel

 if (g_user.hasRole('itil')) {
    // getLabel returns the label for the field listed
    // I'd suggest using getLabelOf as it's supported
    // both on desktop and on mobile / sp
    var oldLabel = g_form.getLabel('comments');
    g_form.setLabel('comments', oldLabel + ' (Customer visible)');
 }

Mobile hasField

 // returns true if form has 'assignment group';
 g_form.hasField('assignment_group');

Mobile removeDecoration

 // this removes a decoration
 g_form.removeDecoration('caller_id', 'icon-star', 'VIP');

Mobile setLabel

 if (g_user.hasRole('itil')) {
    var oldLabel = g_form.getLabel('comments');
    g_form.setLabel('comments', oldLabel + ' (Customer visible)');
 }

Mobile addErrorMessage

Displays an error message at the top of the form

 g_form.addErrorMessage('ERROR!');

Mobile addInfoMessage

Displays an informational message at the top of the form

 g_form.addInfoMessage('The top five fields in this form are mandatory');

Mobile addOption

Adds a choice to a choice list field If the index is not specified, the
choice is added to the end of the list.

Optional: Use the index field to specify a particular place in the list

 g_form.addOption('priority', '6', '6 - Really Low');
 g_form.addOption('priority', '2.5', '2.5 - Moderately High', 3);

Mobile clearMessages

Removes all informational and error messages from the top of the form.

Removes informational and error messages added with
g_form.addInfoMessage() and g_form.addErrorMessage().

 g_form.clearMessages();

Mobile clearOptions

Removes all options from a choice list

 g_form.clearOptions('priority');

Mobile clearValue

Removes any value(s) from the specified field

g_form.clearValue('short_desciption');

Mobile getActionName

Returns the most recent action name or, for a client script, the sys_id
of the UI Action clicked Note: not available to Wizard Client Scripts

 function onSubmit() {
   var action = g_form.getActionName();
   console.log('You pressed ' + action);
 }

Mobile getBooleanValue

Returns false if the field's value is false or undefined, otherwise true
is returned. Useful with checkbox fields Returns true when the checkbox
is checked

 // Returns false if the field value is false or undefined;
 // otherwise returns true.
 var active = g_form.getBooleanValue('active');

Mobile getDecimalValue

 function onChange(control, oldValue, newValue, isLoading) {
   console.log(g_form.getDecimalValue('percent_complete'));
 }

Mobile getDisplayValue

 g_form.getDisplayValue();//returns record displayvalue, not field displayvalue
 g_form.getDispalyValue('caller_id');//returns record displayvalue, not field displayvalue

Mobile getEncodedRecord

 // returns '' or _options.encodedRecord normally that's null
 // I don't see when that would be set to something else.  Doesn't
 // seem to work on catalog items, or on form's in service portal.
 g_form.getEncodedRecord();

Mobile getField

This is undocumented and I havent been able to find or test this yet,
however it comes from this source;
https://community.servicenow.com/community?id=community_question&sys_id=2a151ed0db262b4011762183ca961957$answer_fe97e3bfdb4ef304f21f5583ca961964#answer_fe97e3bfdb4ef304f21f5583ca961964

// this code is to limit a multirowvariableset to two rows
function onLoad() {
    var field = g_form.getField("uk_billing_invoice_details_new");
    if (field != null) {
        field.max_rows_size = 2;
    }
}

Mobile getFieldNames

 g_form.getFieldNames();
 // returns array of strings of fields (and derived fields)

Mobile getIntValue

 function onChange(control, oldValue, newValue, isLoading) {
   console.log(g_form.getIntValue('state'));
 }

Mobile getLabelOf

 if (g_user.hasRole('itil')) {
    var oldLabel = g_form.getLabelOf('comments');
    g_form.setLabelOf('comments', oldLabel + ' (Customer visible)');
 }

Mobile getReference

 function onChange(control, oldValue, newValue, isLoading) {
   var caller = g_form.getReference('caller_id', function(reference){
       if (reference.vip == 'true') {
            console.log('Caller is a VIP!');
       }
   });
}

Mobile getRelatedListNames

 // Returns all related table.refernce related lists
 // This is in the form of an array of strings.
 g_form.getRelatedListNames();

Mobile getSectionNames

 // Returns all section names, whether visible or not.
 // This is in the form of an array of strings.
 g_form.getSectionNames();

Mobile getSysId

 function onLoad() {
    var incSysid = g_form.getSysId();
    console.log(incSysid);
 }

Mobile getTableName

 function onLoad() {
    if (g_form.isNewRecord() {
         var tableName = g_form.getTableName(); //Get the table name
    }
 }

Mobile getUniqueValue

 function onLoad() {
    var incSysid = g_form.getUniqueValue();
    console.log(incSysid);
 }

Mobile getValue

 function onSubmit() {
   if (g_form.getValue('source') == "url"){
       return true;
   }
 }

Mobile getViewName

 // Returns the view name
 // Doesn't seem to work on service portal
 g_form.getViewName();

Mobile hideAllFieldMsgs

 // Hides all field messages.
 g_form.hideAllFieldMsgs();

Mobile hideErrorBox

 // Hides the error message placed by showErrorBox().
 // Whenever possible, use hideFieldMsg() rather
 // than this method whenever possible.
 g_form.hideErrorBox('priority');

Mobile hideFieldMsg

 g_form.hideFieldMsg('priority', false);//hides last message
 g_form.hideFieldMsg('priority', true);//hides all messages

Mobile hideRelatedList

// This method is not available on the mobile platform.
// If this method is run on a mobile platform, no action occurs.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
  if (isLoading || newValue === '') {
    return;
  }
  if(newValue == 'hide'){
    g_form.hideRelatedList('sc_request');
  } else if(newValue == 'show') {
    g_form.showRelatedList('sc_request');
  } else if(newValue == 'hide all'){
    g_form.hideRelatedLists();
  } else if(newValue == 'show all'){
    g_form.showRelatedLists();
  }
}

Mobile hideRelatedLists

 // This method is not available on the mobile platform.
 // If this method is run on a mobile platform, no action occurs.
 function onChange(control, oldValue, newValue, isLoading, isTemplate) {
     if (isLoading || newValue === '') {
         return;
     }
     if (newValue == 'hide') {
         g_form.hideRelatedList('sc_request');
     } else if (newValue == 'show') {
         g_form.showRelatedList('sc_request');
     } else if (newValue == 'hide all') {
         g_form.hideRelatedLists();
     } else if (newValue == 'show all') {
         g_form.showRelatedLists();
     }
 }

Mobile isMandatory

 // Returns true or false if field is mandatory.
 var isPriorityMandatory = g_form.isMandatory('priority');

Mobile isNewRecord

 // returns true if record has a sys_id of -1
 g_form.isNewRecord();

Mobile isReadOnly

 // returns true if field is read only
 g_form.isReadOnly('stage');

Mobile isVisible

 // returns true if field is visible
 g_form.isReadOnly('stage');

Mobile removeOption

 g_form.removeOption('field','value');

Mobile save

 // doesn't appear to work on service portal id=form
 // depends on g_form.submit

Mobile serialize

 // expects true/false
 // true = only "dirty" fields
 var serializedArr = g_form.serialize(false);

Mobile setDisabled

 g_form.setDisabled('quantity',true);// changes field to disabled or not

Mobile setDisplay

 g_form.setDisplay('quantity',true);// changes field to displayed or not

Mobile setFieldPlaceholder

g_form.setFieldPlaceholder('field','placeholder');

Mobile setLabelOf

 g_form.setLabelOf('stage','My custom stage');

Mobile setMandatory

g_form.setMandatory('quantity',true);// changes field to required or not

Mobile setReadOnly

 g_form.setReadOnly('stage',false);// changes field to read only or not

Mobile setReadonly

 g_form.setReadonly('stage',false);// changes field to read only or not

Mobile setSectionDisplay

 // not sure how to test, depends on _options.sections which aren't set most the time
 // i'd guess it's called like this;
 g_form.setSectionDisplay();

Mobile setValue

g_form.setValue('quantity','10');// sets the value to 10

Mobile setVisible

function onLoad() {
  if(this.location.pathname === "/support"){
    try{
      //console.log('Making environment and lifecycle not mandatory and not display');
      g_form.setMandatory('u_environment', false);
      g_form.setMandatory('u_lifecycle_indicator', false);
      g_form.setVisible('u_environment', false);
      g_form.setVisible('u_lifecycle_indicator', false);
    } catch (error){
      console.log('path===/support', error);
    }
  } else {
    try{
    //console.log('Making environment and lifecycle mandatory and display');
      g_form.setMandatory('u_environment', true);
      g_form.setMandatory('u_lifecycle_indicator', true);
      g_form.setVisible('u_environment', true);
      g_form.setVisible('u_lifecycle_indicator', true);
    } catch (error){
      console.log('path!==/support', error);
    }
  }
}

Mobile showErrorBox

The showErrorBox() and hideErrorBox() are still available but simply
call the new methods with type of error. You should use the new methods.

  var scroll = true;
  g_form.showErrorBox('field','message',scroll);

Mobile showFieldMsg

 // parameters are;
 // field, string, info||error, scrollToField
 g_form.showFieldMsg('stage', 'text info', 'info', false);
 g_form.showFieldMsg('stage', 'text erro', 'error', false);

Mobile showRelatedList

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
  if (isLoading || newValue === '') {
    return;
  }
  if(newValue == 'hide'){
    g_form.hideRelatedList('sc_request');
  } else if(newValue == 'show') {
    g_form.showRelatedList('sc_request');
  } else if(newValue == 'hide all'){
    g_form.hideRelatedLists();
  } else if(newValue == 'show all'){
    g_form.showRelatedLists();
  }
}

Mobile showRelatedLists

 function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }
   if(newValue == 'hide'){
     g_form.hideRelatedList('sc_request');
   } else if(newValue == 'show') {
     g_form.showRelatedList('sc_request');
   } else if(newValue == 'hide all'){
     g_form.hideRelatedLists();
  } else if(newValue == 'show all'){
    g_form.showRelatedLists();
  }
}

Mobile submit

 // doesn't appear to work on service portal id=form

Desktop

Desktop addDecoration

Adds an icon on a field's label. This method is available starting with
the Fuji release. Icons available
here
Adding the same item twice is prevented; however, you can add the same
icon with a different title.

Note: This method is not supported by Service Catalog.

 g_form.addDecoration('caller_id', 'icon-star', 'preferred member');
 g_form.addDecoration('caller_id', 'icon-star', 'Mark as Favorite', 'color-green');

Desktop addErrorMessage

Displays the error message at the top of the form.

 g_form.addErrorMessage('This is an error');

Desktop addInfoMessage

Displays an informational message at the top of the form

 g_form.addInfoMessage('The top five fields in this form are mandatory');

Desktop addOption

Adds a choice to a choice list field If the index is not specified, the
choice is added to the end of the list.

Optional: Use the index field to specify a particular place in the list

 g_form.addOption('priority', '6', '6 - Really Low');
 g_form.addOption('priority', '2.5', '2.5 - Moderately High', 3)

Desktop clearMessages

Removes all informational and error messages from the top of the form.

Removes informational and error messages added with
g_form.addInfoMessage() and g_form.addErrorMessage().

 g_form.clearMessages();

Desktop clearOptions

Removes all options from a choice list

 g_form.clearOptions('priority');

Desktop clearValue

Removes any value(s) from the specified field

g_form.clearValue('short_desciption');

Desktop disableAttachments

Prevents new file attachments from being added Hides the paperclip icon.
See also: enableAttachments()

g_form.disableAttachments();

Desktop enableAttachments

Allows new file attachments to be added Shows the paperclip icon. See
also: disableAttachments()

g_form.enableAttachments();

Desktop flash

Flashes the specified color the specified number of times in the field.
Used to draw attention to a particular field.

This method is not supported by Service Catalog.

This method is not available on the mobile platform. If this method is
run on a mobile platform, no action occurs.

The third parameter operates with the following inputs;

Input Action
2 1 second flash
0 2 second flash
-2 3 second flash
-4 4 second flash
g_form.flash('incident.caller_id','red',2);

Desktop getActionName

Returns the most recent action name or, for a client script, the sys_id
of the UI Action clicked Note: not available to Wizard Client Scripts

  function onSubmit() {
   var action = g_form.getActionName();
   console.log('You pressed ' + action);
 }

Desktop getBooleanValue

Returns false if the field's value is false or undefined, otherwise true
is returned. Useful with checkbox fields Returns true when the checkbox
is checked

 // Returns false if the field value is false or undefined;
 // otherwise returns true.
 var active = g_form.getBooleanValue('active');

Desktop getControl

Returns the HTML element for the specified field Compound fields may
contain several HTML elements. Generally not necessary as there are
built-in methods that use the fields on the form

  g_form.getControl('caller_id');//returns html element for field.

Desktop getDecimalValue

Returns the decimal value of the specified field

  g_form.getDecimalValue('percent_complete')

Desktop getElement

Returns the HTML element for the field specified via the ID Compound
fields may contain several HTML elements. Generally not necessary as
there are built-in methods that use the fields on the form

  g_form.getElement('caller_id');//returns html element for field.

Desktop getFormElement

Returns the HTML element for the form.

This method is not available in mobile scripts or Service Portal
scripts.

 //Can't test, not available on the global scope in the console.
 g_form.getFormElement();

Desktop getHelpTextControl

Returns the HTML element of the help text for the specified field.

This method is applicable to service catalog variables only.

 //Can't test, not available on the global scope in the console.
 g_form.getHelpTextControl('myspecialvariable');

Desktop getIntValue

Returns the value of the specified field as an integer An empty value
returns 0

 g_form.getIntValue('priority');//returns 4 as a interger
 g_form.getValue('priority');//returns 4 as a string

Desktop getLabelOf

Gets the plain text value of the field label. This method is available
starting with the Fuji release

 g_form.getLabelOf('caller_id');// returns the displayed label for field

Desktop getOption

Returns the <option> element for a select box named fieldName and
where choiceValue matches the option value Returns null if the field is
not found or the option is not found

 g_form.getOption('priority', 1);// returns html element for <option>

Desktop getReference

Returns the GlideRecord for a specified field getReference() accepts a
second parameter, a callback function Warning: This requires a call to
the server so using this function will require additional time and may
introduce latency to your page

 function onChange(control, oldValue, newValue, isLoading) {
   var caller = g_form.getReference('caller_id', function(reference){
       if (reference.vip == 'true') {
            console.log('Caller is a VIP!');
       }
   });
}

Desktop getSectionNames

Returns all section names, whether visible or not, in an array This
method is available starting with the Fuji release

 g_form.getSectionNames();//returns array of strings;
 // e.g. ["notes", "related_records", "closure_information"]

Desktop getSections

Returns the elements for the form's sections in an array

  g_form.getSectionNames();//returns array of elements;

Desktop getTableName

Returns the name of the table this record belongs to

 g_form.getTableName();//returns string of table, e.g. "incident"

Desktop getUniqueValue

Returns the sys_id of the record displayed in the form

 g_form.getUniqueValue(); // returns sys_id of recrod

Desktop getValue

Returns the value of the specified field

 g_form.getValue('caller_id');// returns value of field

Desktop hideAllFieldMsgs

Hides all field messages. <type> paramter is optional

g_form.hideAllFieldMsgs('info');
g_form.hideAllFieldMsgs();

Desktop hideErrorBox

Hides the error message placed by showErrorBox()

Whenever possible, use hideFieldMsg() rather than this method whenever
possible.

g_form.hideErrorBox('caller_id');

Desktop hideFieldMsg

Hides the message placed by showFieldMsg();

  g_form.hideFieldMsg('caller_id');
  var clearAll = true;
  g_form.hideFieldMsg('caller_id', clearAll);

Desktop hideRelatedList

Hides the specified related list on the form

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
  if (isLoading || newValue === '') {
    return;
  }
  if(newValue == 'hide'){
    g_form.hideRelatedList('sc_request');
  } else if(newValue == 'show') {
    g_form.showRelatedList('sc_request');
  } else if(newValue == 'hide all'){
    g_form.hideRelatedLists();
  } else if(newValue == 'show all'){
    g_form.showRelatedLists();
  }
}

Desktop hideRelatedLists

Hides all related lists on the form

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
  if (isLoading || newValue === '') {
    return;
  }
  if(newValue == 'hide'){
    g_form.hideRelatedList('sc_request');
  } else if(newValue == 'show') {
    g_form.showRelatedList('sc_request');
  } else if(newValue == 'hide all'){
    g_form.hideRelatedLists();
  } else if(newValue == 'show all'){
    g_form.showRelatedLists();
  }
}

Desktop isLiveUpdating

Desktop isMandatory

Returns true while a live update is being done on the record the form is
showing.

This can be used in an onChange() client script to determine if a change
to the record is because of a live update from another session. The
client script can then decide what action to take, or not to take. This
applies to systems using UI16 with live forms enabled.

  g_form.isLiveUpdating();

Desktop isNewRecord

Returns true if the record has never been saved Returns false if the
record has been saved

g_form.isNewRecord();

Desktop isSectionVisible

Returns true if the section is visible Returns false if the section is
not visible or does not exist. This method is available starting with
the Fuji release

g_form.isSectionVisible('patching');

Desktop refreshSlushbucket

You can update a list collector variable.

g_form.refreshSlushbucket('bucket');

Desktop removeDecoration

Removes the icon from the specified field that matches the icon and
title. Note: This method is not supported by Service Catalog.

  g_form.removeDecoration('caller_id','fa-star','VIP');

Desktop removeOption

Removes a specific option from a choice list

g_form.removeOption('priority','1');

Desktop save

Saves the record without navigating away from the record (update and
stay)

g_form.save();

Desktop setDisabled

Grays out field and makes it unavailable

  var bool = true;
  g_form.setDisabled('caller_id', true);

Desktop setDisplay

Displays the field if true. Hides the field if false. This method cannot
hide mandatory fields with no value. If the field is hidden, the space
is used to display other items

  var bool = true;
  g_form.setDisplay('caller_id', true);

Desktop setLabelOf

Sets the plain text value of the field label. This method is available
starting with the Fuji release

if (g_user.hasRole('itil')) {
  var oldLabel = g_form.getLabelOf('comments');
  g_form.setLabelOf('comments', oldLabel + ' (Customer visible)');
}

Desktop setMandatory

Makes the field required if true. Makes the field optional if false.
Best Practice: Use UI Policy rather than this method whenever possible

g_form.setMandatory('quantity',true);// changes field to required or not

Desktop setReadOnly

Makes the field read-only if true Makes the field editable if false.
Note: Both setReadOnly and setReadonly are functional. Best Practice:
Use UI Policy rather than this method whenever possible

g_form.setValue('milestone', milestone);
g_form.setReadonly('end_date', milestone);
g_form.setReadonly('duration', milestone);

Desktop setSectionDisplay

Shows or hides a section Works in both tab and flat modes. This method
is available starting with the Fuji release

function onChange(control, oldValue, newValue, isLoading) {
   //this example was run on a form divided into sections (Change form)
   // and hid a section when the "state" field was changed
   var sections = g_form.getSections();
   if (newValue == '2') {
      g_form.setSectionDisplay(sections[1], false);
   } else {
      g_form.setSectionDisplay(sections[1], true);
   }
}

Desktop setValue

Sets the value and the display value of a field Will display value if
there is no displayValue

g_form.setValue('quantity','10');// sets the value to 10

Desktop setVisible

Displays the field if true. Hides the field if false. If the field is
hidden, the space is left blank. This method cannot hide mandatory
fields with no value

function onLoad() {
  g_form.setVisible('u_environment', false);
}

Desktop showErrorBox

Displays an error message under the specified form field (either a
control object or the name of the field). If the control or field is
currently scrolled off the screen, it will be scrolled to. A global
property (glide.ui.scroll_to_message_field) is available that
controls automatic message scrolling when the form field is offscreen
(scrolls the form to the control or field). The showFieldMsg() method is
a similar method that requires a 'type' parameter

var scroll = true;
g_form.showErrorBox('caller_id','message',scroll)

Desktop showFieldMsg

Displays either an informational or error message under the specified
form field (either a control object or the name of the field). Type may
be either 'info' or 'error.' If the control or field is currently
scrolled off the screen, it will be scrolled to. A global property
(glide.ui.scroll_to_message_field) is available that controls
automatic message scrolling when the form field is offscreen (scrolls
the form to the control or field)

 // parameters are;
 // field, string, info||error, scrollToField
 g_form.showFieldMsg('stage', 'text info', 'info', false);
 g_form.showFieldMsg('stage', 'text erro', 'error', false);

Desktop showRelatedList

Displays the specified related list on the form

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
  if (isLoading || newValue === '') {
    return;
  }
  if(newValue == 'hide'){
    g_form.hideRelatedList('sc_request');
  } else if(newValue == 'show') {
    g_form.showRelatedList('sc_request');
  } else if(newValue == 'hide all'){
    g_form.hideRelatedLists();
  } else if(newValue == 'show all'){
    g_form.showRelatedLists();
  }
}

Desktop showRelatedLists

Displays all related lists on the form

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
  if (isLoading || newValue === '') {
    return;
  }
  if(newValue == 'hide'){
    g_form.hideRelatedList('sc_request');
  } else if(newValue == 'show') {
    g_form.showRelatedList('sc_request');
  } else if(newValue == 'hide all'){
    g_form.hideRelatedLists();
  } else if(newValue == 'show all'){
    g_form.showRelatedLists();
  }
}

Desktop submit

Saves the record User will be taken away from the form, returning them
to where they were previously

g_form.submit();

Desktop activateTab

Desktop addAttribute

Desktop addGlideUIElement

g_form.addGlideUIElement(glideUIElement);

Desktop addNameMapEntry

g_form.addNameMapEntry(nameElement);

Desktop addSecurityReadOnlyFields

Desktop addToCart

This seems to be referenced by an error when using g_form.submit()
from a catalog in a catalog client script.

Desktop addValidator

g_form.addValidator(fld.id, validator.validate);

Desktop

g_form.addWarningMessage('Warning! Please click "Update Application" above to update the application.&nbsp;<b>Otherwise some new features may be missing if the application is not updated.</b>');

Desktop allChangedFieldsFilter

Desktop changedFieldsFilter

Desktop changeElementParent

Desktop changeElementStyle

Desktop disable

Desktop enable

Desktop enableOption

Desktop enableUIPolicyFields

Desktop fieldChanged

Desktop findV2RelatedListName

Desktop getAction

Desktop getControlByForm

g_form.getControlByForm('table').options;

Desktop getDerivedFields

Desktop getDisplayBox

 g_form.getDisplayBox('caller_id'); // returns html element for input
 g_form.getDisplayBox('caller_id').value; // returns html element attribute value

Desktop getDisplayValue

 g_form.getDisplayValue();//returns record displayvalue, not field displayvalue
 g_form.getDispalyValue('caller_id');//returns record displayvalue, not field displayvalue

Desktop getEditableFields

If the form is read only, just return.

var editableFields = g_form.getEditableFields();
if (editableFields.indexOf("report_title") < 0) {
  console.log('editable fields contains report_title');
}

Desktop getGlideUIElement

 var serverURLElement = g_form.getGlideUIElement('server_url');

Desktop getLabel

var label = g_form.getLabel('comments') + ' (' + getMessage('Customer visible') + ')';
g_form.setLabel('comments', label);

Desktop getMissingFields

 g_form.getMissingFields();

Desktop getNiBox

Desktop getOptionControl

We can access the option control to get the name of the operation.

var optionControl = g_form.getOptionControl('operation');
var operationText;
if (optionControl) {
  var option = g_form.getOption('operation', g_form.getOptionControl('operation').value);
  operationText = option.text;
}

Desktop orderNow

This seems to be referenced by an error when using g_form.submit()
from a catalog in a catalog client script.

Desktop getParameter

var tblName = g_form.getTableName();
var fromRelList = g_form.getParameter('sysparm_from_related_list');
var _module = g_form.getParameter('sysparm_userpref_module');
var listQuery = g_form.getParameter('sysparm_record_list');
var stackName = g_form.getParameter('sysparm_nameofstack');
var gotoUrl = g_form.getParameter('sysparm_goto_url');
var deleteUrl = g_form.getParameter('sysparm_referring_url');
var returnUrl = deleteUrl ? deleteUrl : returnUrl;

Desktop getPrefixHandler

var handler = g_form.getPrefixHandler(fieldName);
handler.getObject().setReadOnly(handler.getFieldName(), show)

Desktop getRelatedListNames

Desktop getScope

Desktop getTabNameForField

Desktop getTitle

Desktop getViewName

if(g_form.getViewName() === "business_case_view"){
  g_form.setDisplay("state", false);
}

Desktop hasAttribute

Desktop hasField

if(g_form.hasField('schedule'))
  schedule = g_form.getValue('schedule');
}

Desktop hasFieldMsgs

Desktop isDatabaseView

Desktop isDisabled

If the user can't set the field, we shouldn't touch it.

if (g_form.isDisabled('element'))
  return;

Desktop isDisplayNone

Desktop isEditableField

Desktop isInteger

Desktop isNumeric

Desktop isReadOnly

var taskTableCtrl = g_form.getControl("task_table");
if (!taskTableCtrl || g_form.isReadOnly(taskTableEle, taskTableCtrl))
  return;

Desktop isTemplateCompatible

Desktop isUserPersonalizedField

Desktop isVisible

 if(serverURLElement && serverURLControl && g_form.isVisible(serverURLElement, serverURLControl)) {
   var urlajax = new GlideAjax('LDAPURLClientUtils');
 }

Desktop mandatoryCheck

If we have unfilled mandatory fields then do not progress.

if (!g_form.mandatoryCheck()) {
  return;
}

Desktop onSubmit

Desktop registerHandler

if(fieldName != null && fieldName !== undefined)
  g_form.registerHandler(fieldName, filterObj);

Desktop registerPrefixHandler

Desktop removeAllDecorations

Desktop removeContextItem

Desktop removeCurrentPrefix

Desktop removeItem

Desktop resetPersonalizeHiddenFields

Desktop resolveLabelNameMap

id = id.startsWith('IO:') ? id : 'IO:' + id;
return g_form.resolveLabelNameMap(id);

Desktop resolveNameMap

var locElementId = "sys_display." + g_form.resolveNameMap(fieldMappings.location);

Desktop resolvePrettyNameMap

Desktop serialize

ajax.addParam("sysparm_sys_id", g_form.getUniqueValue());
ajax.addParam("sysparm_form_fields", g_form.serialize());
ajax.addParam("sysparm_test_from_form", "true");

Desktop serializeChanged

dd.setPreference('sysparm_notification_id', sysId);
dd.setPreference('sysparm_changed_fields',g_form.serializeChangedAll());
dd.render();

Desktop serializeChangedAll

dd.setPreference('sysparm_notification_id', sysId);
dd.setPreference('sysparm_changed_fields',g_form.serializeChangedAll());
dd.render();

Desktop serializeTargetFields

Desktop setAction

Desktop setDisabledControl

Desktop setLiveUpdating

Desktop setMandatoryOnlyIfModified

Desktop setReadonly

g_form.setValue('milestone', milestone);
g_form.setReadonly('end_date', milestone);
g_form.setReadonly('duration', milestone);

Desktop setRequiredChecked

Desktop setScope

Desktop setSensitiveDisplayValue

Desktop setStreamJournalFieldsDisplay

if(g_form.setStreamJournalFieldsDisplay)
        g_form.setStreamJournalFieldsDisplay(false);

Desktop setTemplateValue

if (window.g_form) {
  g_form.setTemplateValue("template", "");
}

Desktop setUserDisplay

Desktop setValidation

 g_form.setValidation("after", false);

Desktop setVariablesReadOnly

g_form.setVariablesReadOnly(true);

Desktop validate