<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question View rule isn't working in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/view-rule-isn-t-working/m-p/1577966#M234892</link>
    <description>&lt;P&gt;I'm trying to filter views based on roles so I made a view rule with a script. It's the same script that most of users applied to filter views but in my case it's not working&lt;BR /&gt;&lt;BR /&gt;role: Prueba_view_role&lt;BR /&gt;View: prueba_vista_roles&lt;/P&gt;
&lt;PRE class="language-markup"&gt;&lt;CODE&gt;(function overrideView(view, is_list) {

	// Add your code here
	

	if (gs.hasRoleExactly('Prueba_view_role')){
		answer = "prueba_vista_roles";}
	
	
})(view, is_list);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I tried other alternatives (e.g. adding "else" part) but there was no solution.&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 18pt;"&gt;&lt;STRONG&gt;I have a problem with the script or there is a problem with view rules?&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Jul 2022 11:50:57 GMT</pubDate>
    <dc:creator>Leonel Sandroni</dc:creator>
    <dc:date>2022-07-26T11:50:57Z</dc:date>
    <item>
      <title>View rule isn't working</title>
      <link>https://www.servicenow.com/community/developer-forum/view-rule-isn-t-working/m-p/1577966#M234892</link>
      <description>&lt;P&gt;I'm trying to filter views based on roles so I made a view rule with a script. It's the same script that most of users applied to filter views but in my case it's not working&lt;BR /&gt;&lt;BR /&gt;role: Prueba_view_role&lt;BR /&gt;View: prueba_vista_roles&lt;/P&gt;
&lt;PRE class="language-markup"&gt;&lt;CODE&gt;(function overrideView(view, is_list) {

	// Add your code here
	

	if (gs.hasRoleExactly('Prueba_view_role')){
		answer = "prueba_vista_roles";}
	
	
})(view, is_list);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I tried other alternatives (e.g. adding "else" part) but there was no solution.&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 18pt;"&gt;&lt;STRONG&gt;I have a problem with the script or there is a problem with view rules?&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2022 11:50:57 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/view-rule-isn-t-working/m-p/1577966#M234892</guid>
      <dc:creator>Leonel Sandroni</dc:creator>
      <dc:date>2022-07-26T11:50:57Z</dc:date>
    </item>
    <item>
      <title>Re: View rule isn't working</title>
      <link>https://www.servicenow.com/community/developer-forum/view-rule-isn-t-working/m-p/1577967#M234893</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;hasroleexactly won't work here , you have to use HasRole only.&lt;/P&gt;
&lt;PRE class="language-markup"&gt;&lt;CODE&gt;(function overrideView(view, is_list) {

	// Add your code here
	

	if (gs.hasRole('Prueba_view_role')){
		answer = "prueba_vista_roles";}
	
	
})(view, is_list);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;hasroleexactly works with Client side and you have to use g_form.hasRoleExactly with client side whereas you have to use gs.hasRole with server side&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2022 11:58:51 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/view-rule-isn-t-working/m-p/1577967#M234893</guid>
      <dc:creator>Musab Rasheed</dc:creator>
      <dc:date>2022-07-26T11:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: View rule isn't working</title>
      <link>https://www.servicenow.com/community/developer-forum/view-rule-isn-t-working/m-p/1577968#M234894</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;hasRoleExactly() is not a valid function on gs object&lt;/P&gt;
&lt;P&gt;use hasRole()&lt;/P&gt;
&lt;P&gt;(function overrideView(view, is_list) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; // Add your code here&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if (gs.&lt;STRONG&gt;hasRole&lt;/STRONG&gt;('Prueba_view_role'))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; answer = "prueba_vista_roles";&lt;/P&gt;
&lt;P&gt;})(view, is_list);&lt;/P&gt;
&lt;P&gt;Regards&lt;BR /&gt;Ankur&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2022 12:02:30 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/view-rule-isn-t-working/m-p/1577968#M234894</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2022-07-26T12:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: View rule isn't working</title>
      <link>https://www.servicenow.com/community/developer-forum/view-rule-isn-t-working/m-p/1577969#M234895</link>
      <description>&lt;P&gt;It's a piece of cake...haha!!! Thanks, now it's working!!!&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2022 12:16:15 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/view-rule-isn-t-working/m-p/1577969#M234895</guid>
      <dc:creator>Leonel Sandroni</dc:creator>
      <dc:date>2022-07-26T12:16:15Z</dc:date>
    </item>
  </channel>
</rss>

