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

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 6-9: ServiceNow Java scripting Challenge**

### **Statement of Work :**

**Write a code using the following methods**

1. ShowFieldMessage()
2. **hideAllFieldMsgs()**
3. **hideRelatedList(String listTableName)**
4. **isMandatory(String fieldName)**
5. **isNewRecord()**
6. **isSectionVisible(String sectionName)**
7. **removeOption(String fieldName, String choiceValue)**
8. **save()**
9. **setLabelOf(String fieldName, String label)**
10. **setMandatory(String fieldName, Boolean mandatory)**
11. **setReadOnly(String fieldName, Boolean readOnly)**
12. **showRelatedLists()**
13. **submit()**

### **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. **showFieldMsg()**
– Displays either an informational or error message under the specified form field
– Method signature : **showFieldMsg(String field, String message, String type)**
– Input parameters :
– field = String = Name of the field or control.
– message = String = Message to display.
– type = String ==”error”,”info”, or “warning”.
– Return : void
2. **hideAllFieldMsgs()**
– Hides all field messages.
– Method signature : **hideAllFieldMsgs()**
– Input parameters : void
– Return : void
3. **isNewRecord()**
– Returns true if the record has never been saved.
– Method signature : **isNewRecord()**
– Input parameters : void
– Return : Boolean =Returns true if the record has not been saved; otherwise false.
4. **isSectionVisible()**
– Returns true if the section is visible.
– Method signature : **isSectionVisible(String sectionName)**
– Input parameters : String =Section name
– Return : Boolean =Returns true when the section is visible; otherwise, false is returned.
5. **removeOption()**
– Removes the specified option from the choice list.
– Method signature : **removeOption(String fieldName, String choiceValue)**
– Input parameters :
– fieldName = String = Name of the field.
– choiceValue = String = The value stored in the database. This is not the label.
– Return : void
6. **save()**
– Saves the record without navigating away (update and stay).
– Method signature : **save()**
– Input parameters : void
– Return : void
7. **setLabelOf()**
– Sets the plain text value of the field label.
– Method signature : **setLabelOf(String fieldName, String label)**
– Input parameters :
– fieldName = String = The field name.
– label =String = The field text label.
– Return : void
8. **setMandatory()**
– Makes the specified field mandatory.
– Method signature : **setMandatory(String fieldName, Boolean mandatory)**
– Input parameters :
– fieldName = String = The field name.
– mandatory = Boolean ==When true makes the field mandatory.
– Return : void
9. **setReadOnly()**
– Makes the specified field read-only or editable.
– Method signature : **setReadOnly(String fieldName, Boolean readOnly)**
– Returns
– Boolean =True if the field is required, false otherwise.
– Input parameters :
– fieldName =String = The field name.
– readOnly =Boolean ==When true makes the field mandatory.

Please make sure to like the video and subscribe to my channel to get the latest updates on my future videos.

Regards,
Amit Gujarathi

technomonkadmin

View all posts

Add comment

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