Change view dynamically with business rule

ipt_Phil
Giga Contributor

I was wondering if there is a way to change a form view with a display business rule. I have a workflow that creates various tasks and this workflow can be started for various types of requests. Each task type of each request type has its own view, and instead of having to create 100 view rules I would like to have some dynamic way to show the correct view when opening a task. Basically I want a display business rule   in which i get 2 fields of the task and create the view name with those, and then I want to load the view. However I'm not sure if and how I can load a view in a business rule. Anyone knows if this is possible? I know about 'switchView' but it only works in client scripts and not in business rules.

Regards, Phil

6 REPLIES 6

Uncle Rob
Kilo Patron

You can use View Rules to make sure you arrive at the right view.   However, I wonder if some of what you're trying to accomplish can't be done with variables and client scripts.   It sounds as if some of the data elements you want are really specific to a component of work on a specific workflow.   That kind of thing is *WAY* better to handle as a variable that comes into play later in the workflow and is only visible on the sc_task.   It'll stop a ton of column bloat on your sc_task table and reduce the nightmare of view management you're just stepping into.


Brad Tilton
ServiceNow Employee
ServiceNow Employee

Other than view rules, you can set a view through a url parameter as in the following article, so your display business rule (or onload client script) could redirect the user to the corresponding view.



Navigating by URL - ServiceNow Wiki



That being said, why do you have so many views and task types? Having a default view and then variables that change for each request type is really the best way to handle the service catalog. As you're discovering here, having a large number of views can be pretty cumbersome and difficult to maintain.


Hi Brad,



User will have to create a specific view for that and i hope he is not willing to however i liked your idea.



Don't you think i may impact the user experience. Since when user will have a slow network he might see two forms details which needs to be hidden.



Regards,


Atul Kumar


ipt_Phil
Giga Contributor

I know it works perfectly fine with view rules, but I would have to create 100+ of them... The thing is I have about 15 different type of "requests", all those requests run through the same workflow, which creates about 10 different tasks. Which information is shown in which order to a user (and which info is readonly/required) when working a task depends on the request type and the task type, so I have the 15 x 10 different possibilities (views) I can show. I would prefer to have one script that reads the necessary information (2 variables of the task) and shows the correct view according to those variables values. I guess I can try with the redirect solution but still the user will probably see the load from form to form, similarly to when using client scripts.



Basically I want exactly what a view rule does, except I don't want to specify one single view for a condition, but rather show one dynamically based on the 2 variables of the task.