custom view should be set as default for creating new request

Athena Mathews
Tera Contributor

Hi Community!

 

This is about the view rule requirement. I have seen a similar post and that did solve part of my issue.

What I have done so far is:

I have created a custom view "Deployment_view" on change request and I need to make it a default view such that when anyone creates a new change request, they will only be able to create it in this deployment view. Thankful to another post, I could achieve it. This is the script :

 

(function overrideView(view, is_list) {
    if (is_list) {
        answer = "Deployment_view";
        return answer;
    }
	
    var url = gs.action.getGlideURI().getMap();
    var sys_id = url.get('sys_id');
    if (sys_id) {
        var grchg = new GlideRecord('change_request');
        if (grchg.get(sys_id)) {
            if (grchg.correlation_id == "") {
                answer = 'Deployment_view';
            } else
                answer = "Integration_view";
        }
    }
	
})(view, is_list);

So as per our requirement, when user goes to module change > click on all > new > he could create it in Deployment view only and based on the condition mentioned, post creation ticket will only be in either deployment_view or integration_view.

What needs to be done:

This is good so far but when user clicks on change module > create new , then this page opens up to select either normal/emergency/ standard and then when we click on say normal, the ticket is still in default view ., How do I set this "create new" module so that even from here, tickets can only be created in "Deployment_view"?

create new.jpg

 

Thanks,

Athena

 

1 ACCEPTED SOLUTION

Hi @Athena Mathews ,

This will work too!

Great find.

 

Best Regards
Aman Kumar

View solution in original post

5 REPLIES 5

Aman Kumar S
Kilo Patron

Hi @Athena Mathews ,

You will  need to add arguments in the application module:

&sysparm_view=deployment_view&sysparm_view_forced=true

 

 

Best Regards
Aman Kumar

Hi @Aman Kumar S ,

I tried adding this part to "create new" module's arguments

createnewv.jpg

still when opened, it is in default view

defaultv.jpg

deploymentv.jpg

 

If its change request, you will not directly end up at the change request form but through the landing page.

One thing you can do here is to configure a view rule, where condition would be 

if(current.isNewRecord()){

    answer = "Deployment_view";

}

Best Regards
Aman Kumar

Hello @Aman Kumar S ,

Thanks! I did try with the mentioned script in view rule, but for some reason it didn't work.

What I observed is that, when "Deployment view" is selected in list view and then I try to create new from list, the link it takes me is different from the OOB default link.

what I mean is, this is the link that I get when I click on existing "Create new":

sn_new_chg_origin=module

And when I select deployment view in list and then create new ticket from list, it took me to this landing page:

sn_chg_model_ui_landing.do?sys_id=-1&sys_target=change_request&sysparm_fixed_query=&sysparm_group_sort=&sysparm_query=&sysparm_referring_url=change_request_list.do%253Fsys_id%253D-1%2526sys_target%253Dchange_request%2526sysparm_fixed_query%253D%2526sysparm_group_sort%253D%2526sysparm_query%253D%2526sysparm_target%253D%2526sysparm_view%253DDeployment_view&sysparm_target=&sysparm_view=Deployment_view

so what I did is, I created a new module say "create deployment change" and then in arguments I added this second link. This seems to solve my issue. 

Thanks for helping!

I just wanted to check with you if it is okay to go with this approach and if it is according to the best practices?

 

Thanks,

Athena.