ServiceNow introduction to GlideForm API | ServiceNow Client scripts | ServiceNow JavaScripts – 3

Hi There,

I hope you’re doing great.

With the participation in the ServiceNow Javascripting Challenge led by [@Gagan Jolly](https://www.servicenow.com/community/user/viewprofilepage/user-id/248249) , I m learning a lot. I thought I should share my learning on the Now community also

### **Day 2: ServiceNow Java scripting Challange**

### **Statement of Work :**

**Write a code using the following methods**

1. getActionName()
2. getBooleanValue(String fieldName)
3. getDecimalValue(String fieldName)
4. getDisplayValue(String fieldName)
5. getHelpTextControl(String fieldName)
6. getLabelOf(String fieldName)
7. **getOption(String fieldName, String choiceValue)**
8. getReference(String fieldName, Function callBack)
9. **getRelatedListNames()**
10. **getSectionNames()**
11. **getTableName()**
12. **getUniqueValue()**

### **Solution :**

Let’s first try to understand what ServiceNow GlideForm API means

**GlideForm :**

– The GlideForm API provides methods to customize forms.
– Works on the client side only

Lets  look into diffrent GlideForm Methods :

1. getActionName()
– Returns the most recent action name, or, for a client script, the sys_id of the UI action clicked.
– Method Signature : **getActionName()**
– Input parameters :
– None
– Returns :
– Void
2. **getBooleanValue(String fieldName)**
– Returns a Boolean value for the specified field.
– Method Signature : **getBooleanValue(String fieldName)**
– Input parameters :
– fieldName = String =. Name of the field.
– Returns :
– Boolean == Returns false if the field value is false or undefined; otherwise returns true.
3. getActionName()
– Returns the most recent action name, or, for a client script, the sys_id of the UI action clicked.
– Method Signature : **getActionName()**
– Input parameters :
– None
– Returns :
– Void
4. **getLabelOf**()
– Returns the plain text value of the field label.
– Method Signature : **getLabelOf()**
– Input parameters :
– fieldName =⇒ String =⇒ The field name
– Returns :
– String =⇒. The label text.
5. **getOption()**
– Returns the option element for a selected box named fieldName where choiceValue matches the option value.
– Method signature : **getOption(String fieldName, String choiceValue)**
– Input parameters :
– fieldName =⇒. String =⇒ Name of the field.
– choiceValue =⇒ String =⇒ Value of the option.
– Return :
– HTMLElement =⇒ The HTMLElement for the option.
6. **getReference()**
– Returns the GlideRecord for a specified field.
– If a callback function is present, this routine runs asynchronously.
– Method signature : **getReference(String fieldName, Function callBack)**
– Input parameters :
– fieldName =⇒ String =⇒ Name of the field.
– callBack =⇒ Function =⇒ Name of the call back function.
– Returns :
– GlideRecord =⇒ GlideRecord object for the specified field.
7. **getRelatedListNames()**
– Returns an array of related lists from the current form in the order in which they appear on that form.
– Method signature :
– Input parameters :
– void
– Returns :
– Array =⇒ Array of related lists from the current form in the order in which they appear on that form.
8. **getSectionNames()**
– Returns all section names, whether visible or not.
– Method signature : **getSectionNames()**
– Input parameters :
– Void
– Returns :
– Array of strings =⇒ The section names.
9. **getTableName()**
– Returns the name of the table to which this record belongs.
– Method signature : **getTableName()**
– Input parameter :
– void
– Returns
– String =⇒ Name of the table
10. **getUniqueValue()**
– Returns the sys_id of the record displayed in the form.
– Method signature : **getUniqueValue()**
– Input parameters :
– void
– Returns :
– String record sys_id

**Please be sure to bookmark this article and mark it as Helpful if you thought it helpful.**

Regards,

Amit Gujarathi

technomonkadmin

View all posts

Add comment

Your email address will not be published. Required fields are marked *