Hello, can someone please explain in what order view rules are getting executed in SNOW ?

snehabhagwat
Kilo Explorer

Hello, can someone please explain in what order view rules are getting executed in SNOW ? based on my reverse eng , assuming that its based on created date and time.

4 REPLIES 4

Jaspal Singh
Mega Patron
Mega Patron

Hi Sneha,



Are you referring to order of execution of view rule if there exists more than 1 more same table. If so, then it is totally depended on conditions/filters/scripts that are written for its execution.


Hi Jaspal,



Thanks for your response and apologies if my content was not clear . let me give you an example which i was trying to execute and came across this question . i have created a simple form which has few Text fields and a choice type field which has choice options like opt 1, opt 2. i have created 2 view rules for this form . Rule 1 - just created a rule with no condition . Rule 2 - created another rule with a condition choice option opt 1.



Now say in the view rule table if rules are created in the below order


Rule 1 - created first


Rule 2 -   Created afterwords


With the above order when form is loaded with any value of choice type it always gives Rule 1 as view.


If you change the order of insertion say you make


Rule 2 - created first


Rule 1 - Created afterwords


It gives view tagged to rule 2 when choice option is selected as opt1 , and gives view tagged to rule 1 when condition is not matched.



with the above example i need to know in what order does the engine execute the view rules . i know if two or more rules get satisfied then engine decides which rule to apply . In other words JVM picks these rules in the background , but i need to know how does JVM picks these rules , sply in which order it picks and execute .



Hope this gives more info .



Thanks,


Sneha


Michael Culhan1
Kilo Sage

For what it's worth: I found having more than one view rule on the same table to have unpredictable behavior.  I ended up putting all the logic in one view rule.

Hello,

This is a 4 year old post, but you can have more than one view rule on a table. If they're configured correctly, there'd be no unpredictable behavior. There are scenarios when using the non-advanced setup...so low-code/no-code approach and the condition builder, you can't meet multi-scenario requirements with just the one view rule or even if you tried to fit it in to one, you run the risk of just lengthy code, etc.

So recapping...multiple view rules for the same table are fine, if they're not conflicting and if they're setup properly.

Documentation such as this, while covering another topic, do show that multiple view rules are "a thing": https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0523472

@snehabhagwat But...since this post was resurrected and doesn't have a Correct answer. View rules can have an "Execution Order" applied to it to determine the order in which they run:

find_real_file.png

You simply need to add the field to the form or add the column to list view as seen in the screenshot and set it. The lower the number the earlier it executes (the higher the number, the later it executes).

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!