The CreatorCon Call for Content is officially open! Get started here.

Role Configuration with Form

Arthur Sanchez
Giga Guru

Help me here guys, I have an application with 4 forms:

  • User
  • Support
  • Manager
  • SupUser

3 list layouts:

  • User
  • Support
  • Manager

And the roles:

  • user,
  • support
  • manager
  • supuser
I created supuser so that it could enter the SupUser form, so that supports can also create tickets in a separate module, the problem is, it is entering the Support form to create a new ticket, and it should enter directly into SupUser to create , the Support form is for him to receive a ticket
Captura de tela 2024-05-09 090042.pngCaptura de tela 2024-05-09 090054.pngCaptura de tela 2024-05-09 090119.png
The flow is:
  1. the user creates 1 ticket
  2. support receives it and downloads it or changes the queue
  3. the manager monitors
Now I'm trying to implement a module where support can also create a ticket, but I can't direct it to the correct form when creating it, I have to have 2 forms for support, 1 for him to create a ticket and another for him to receive the tickets that were created by the user or other support. PLS HELP ME
11 REPLIES 11

 

(function overrideView(view, is_list) {
    var answer = ""; 

    if (gs.hasRole("x_1316384_tickets.tickets_user"))
        answer = "user";  

    if (gs.hasRole("x_1316384_tickets.tickets_supuser"))
        answer = "supuser";  

    if (gs.hasRole("x_1316384_tickets.tickets_seg_acs_1") ||
        gs.hasRole("x_1316384_tickets.tickets_seg_acs_2") ||
        gs.hasRole("x_1316384_tickets.tickets_seg_ims_1") ||
        gs.hasRole("x_1316384_tickets.tickets_seg_ims_2") ||
        gs.hasRole("x_1316384_tickets.tickets_seg_sms_1") ||
        gs.hasRole("x_1316384_tickets.tickets_seg_sms_2") ||
        gs.hasRole("x_1316384_tickets.tickets_ti_app_1") ||
        gs.hasRole("x_1316384_tickets.tickets_ti_app_2") ||
        gs.hasRole("x_1316384_tickets.tickets_ti_brm_1") ||
        gs.hasRole("x_1316384_tickets.tickets_ti_brm_2") ||
        gs.hasRole("x_1316384_tickets.tickets_ti_capta_1") ||
        gs.hasRole("x_1316384_tickets.tickets_ti_capta_2") ||
        gs.hasRole("x_1316384_tickets.tickets_ti_gpp_1") ||
        gs.hasRole("x_1316384_tickets.tickets_ti_gpp_2"))
        answer = "support";  

    if (gs.hasRole("x_1316384_tickets.tickets_manager"))
        answer = "manager";  

})(view, is_list);

 

That way? It didn't work for me, did it work for you?

(function overrideView(view, is_list) {

	if(gs.getUser().hasRole("x_1316384_tickets.tickets_user"))
		answer = "User";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_supuser"))
		answer = "SupUser";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_seg_acs_1"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_seg_acs_2"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_seg_ims_1"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_seg_ims_2"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_seg_sms_1"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_seg_sms_2"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_ti_app_1"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_ti_app_2"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_ti_brm_1"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_ti_brm_2"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_ti_capta_1"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_ti_capta_2"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_ti_gpp_1"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_ti_gpp_2"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_manager"))
		answer = "Manager";  // set the new view to answer

})(view, is_list);

My View Rule

CezaryBasta
Tera Guru

The view names in your view rule should be lowercase.

Also remember that:

View rules do not apply to users who have no role. View rules do not always apply if there are existing user preference entries on the instance. Delete the user preference entry and clear the system cache to make sure the respective view rule applies. You can clear the system cache by appending cache.do to the instance URL. For example, instance_name.service-now.com/cache.do.

https://docs.servicenow.com/bundle/washingtondc-platform-user-interface/page/administer/navigation-a...

--
See more of my content here.

 

(function overrideView(view, is_list) {

	if(gs.getUser().hasRole("x_1316384_tickets.tickets_user"))
		answer = "User";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_supuser"))
		answer = "SupUser";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_seg_acs_1"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_seg_acs_2"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_seg_ims_1"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_seg_ims_2"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_seg_sms_1"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_seg_sms_2"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_ti_app_1"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_ti_app_2"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_ti_brm_1"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_ti_brm_2"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_ti_capta_1"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_ti_capta_2"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_ti_gpp_1"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_ti_gpp_2"))
		answer = "Support";  // set the new view to answer
	
	if(gs.getUser().hasRole("x_1316384_tickets.tickets_manager"))
		answer = "Manager";  // set the new view to answer

})(view, is_list);

 

So should I change the answer to lowercase? but this is exactly the names of the forms and the list layout, and they are all working, because of 1 role do they all have to change?

There is a difference between display name and internal name. Give it a chance with lowercase. You can also check the URL when vieweing the form in specific view - there should be a sysparm_view parameter with the internal name.

--
See more of my content here.