How to get only name of field under form tab in client side

ramancoder
Tera Contributor

Hi Everyone.

 

Anyone can help me to get  only name of field under form tab in client side script.

For example resolution information  tab , I need the name of column only under resolution information tab on load of form to make the filed non mandatory to achieve similar use case.

ramancoder_0-1698039342538.png

 

1 ACCEPTED SOLUTION

Tai Vu
Kilo Patron
Kilo Patron

Hi @ramancoder ,

The fields in a section are stored in the Section Elements [sys_ui_element] table.

TaiVu_0-1698043551033.png

Section: Resolution Information (Default View)
URL: https://<instance_name>/sys_ui_element_list.do?sysparm_query=sys_ui_section%3D992099dd0a0006413c77c9...

Just query to that table and you can have all the fields name under a specific section.

1. Define a function in an AJAX Script Include.

Sample below.

    getResolutionFields: function() {
        var sectionID = gs.getProperty('cl.incident.section.resolution_information'); //992099dd0a0006413c77c9a4b7d410c0
        var arrElement = [];
        var grElement = new GlideRecord('sys_ui_element');
        grElement.addQuery('sys_ui_section', sectionID);
        grElement.addNullQuery('type');
        grElement.query();
        while (grElement.next()) {
            arrElement.push(grElement.getValue('element'));
        }
        return arrElement.join(',');
    },

2. Call the function in the Client Script and you will have all the fields in response.

 

Let me know if it works for you.

 

Cheers,

Tai Vu

 

View solution in original post

2 REPLIES 2

Tai Vu
Kilo Patron
Kilo Patron

Hi @ramancoder ,

The fields in a section are stored in the Section Elements [sys_ui_element] table.

TaiVu_0-1698043551033.png

Section: Resolution Information (Default View)
URL: https://<instance_name>/sys_ui_element_list.do?sysparm_query=sys_ui_section%3D992099dd0a0006413c77c9...

Just query to that table and you can have all the fields name under a specific section.

1. Define a function in an AJAX Script Include.

Sample below.

    getResolutionFields: function() {
        var sectionID = gs.getProperty('cl.incident.section.resolution_information'); //992099dd0a0006413c77c9a4b7d410c0
        var arrElement = [];
        var grElement = new GlideRecord('sys_ui_element');
        grElement.addQuery('sys_ui_section', sectionID);
        grElement.addNullQuery('type');
        grElement.query();
        while (grElement.next()) {
            arrElement.push(grElement.getValue('element'));
        }
        return arrElement.join(',');
    },

2. Call the function in the Client Script and you will have all the fields in response.

 

Let me know if it works for you.

 

Cheers,

Tai Vu

 

Thank you. It is Working.