Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to access the field value in a view rule script

babloo
Giga Contributor

Hi

We need to get a field value in a view rule script.The current object is not accessible from it.we did try with business rule as well but it didn't work.

4 REPLIES 4

larstange
Mega Sage

Hi



It looks like this is not possible:



Current object not available in View Rule Script


Johan Graden
Tera Contributor

I see this post is a few years old and you might already have a solution for this. Otherwise you can access the current record like this from a View Rule, just replace table_name and field_name:

 

 

var url = gs.action.getGlideURI().getMap();
var sysId = url.get('sys_id');

var gr = new GlideRecord('table_name');
if (gr.get(sysId)) {

 gr.field_name;

}

Johan you are my hero! This is just what I needed. Thank you!!

Hersh D
Giga Expert

Found this on another thread.

Navigation handlers (sys_navigator) can be used for scripting view rules - the handler script has access to the current object

https://docs.servicenow.com/bundle/london-platform-user-interface/page/administer/navigation-and-ui/...