Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Suggy 

 

I think OOTB , there is no option to get that. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

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

Suggy
Giga Sage

So there is no easy way? One should use a script for that 😞

Hi @Suggy ,

 

If u are not comfortable with the script then u can better check each view manually by opening from the record or u can open form designer n from there u can change views of the form n check manually.

 

Thanks,

Danish