How to find out on which form VIEW a field is present?

Suggy
Giga Sage

On a table, there are 15 VIEWS created. I need to seach for a field say 'ABC'.

How to know in which of the 15 views this field 'ABC' is avaialble.

 

I checked form views, sections, elements etc etc.. but couldnt find a way 😞

Appreciate if you can help 🙂

1 ACCEPTED SOLUTION

Mark Manders
Mega Patron

This may get you started, but please, check all the variables.

var viewGR = new GlideRecord('sys_ui_view');
viewGR.addQuery('name', 'my_table');
viewGR.query();
while (viewGR.next()) {
    var sectionGR = new GlideRecord('sys_ui_section');
    sectionGR.addQuery('view', viewGR.sys_id);
    sectionGR.query();
    while (sectionGR.next()) {
        var elementGR = new GlideRecord('sys_ui_element');
        elementGR.addQuery('section', sectionGR.sys_id);
        elementGR.addQuery('element', 'my_field');
        elementGR.query();
        if (elementGR.next()) {
            gs.print('View "' + viewGR.getValue('name') + '" contains "my_field".');
        }
    }
}

Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron

@Suggy 

What's your business requirement?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader