<?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 Re: I want to write a script in ACL in ITSM forum</title>
    <link>https://www.servicenow.com/community/itsm-forum/i-want-to-write-a-script-in-acl/m-p/3008386#M525567</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/230256"&gt;@Pooja Khatri&lt;/a&gt;&amp;nbsp;Try this&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var user = gs.getUser();
var userId = user.getID();
var hasChangeManagerRole = user.hasRole('change_manager');
var isRequestedBy = (current.requested_by == userId);
var isAssignedTo = (current.assigned_to == userId);
var isAdmin = user.hasRole('admin');
if (hasChangeManagerRole || isRequestedBy || isAssignedTo) {
    answer = true;
} else if (isAdmin) {
    answer = isRequestedBy || isAssignedTo;
} else {
    answer = false;
}&lt;/LI-CODE&gt;</description>
    <pubDate>Sat, 03 Aug 2024 18:22:38 GMT</pubDate>
    <dc:creator>Sid_Takali</dc:creator>
    <dc:date>2024-08-03T18:22:38Z</dc:date>
    <item>
      <title>I want to write a script in ACL</title>
      <link>https://www.servicenow.com/community/itsm-forum/i-want-to-write-a-script-in-acl/m-p/3008195#M525556</link>
      <description>&lt;P&gt;Hello All ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a requirement , where there is a pre-existing "Write" ACL on the change request table for the "close code" field .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to write a script which will allow only the "requested by" , "assigned to" and the change manager role users to edit the close code fields , even for the admin users that field should be read - only , if the admin user is the requested by or assigned to only during that time they should be able to edit it .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I implement this functionality ?&lt;/P&gt;</description>
      <pubDate>Sat, 03 Aug 2024 06:29:18 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/i-want-to-write-a-script-in-acl/m-p/3008195#M525556</guid>
      <dc:creator>Pooja Khatri</dc:creator>
      <dc:date>2024-08-03T06:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: I want to write a script in ACL</title>
      <link>https://www.servicenow.com/community/itsm-forum/i-want-to-write-a-script-in-acl/m-p/3008234#M525558</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/230256"&gt;@Pooja Khatri&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use the following script in your ACL bij checking the 'Advanced' checkbox:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;answer = false;

var userId = gs.getUserID();

if (
	current.getValue("assigned_to") == userId ||
	current.getValue("requested_by") == userId ||
	gs.hasRole("change_manager")
) {
	answer = true;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Make also sure that you add the appropriate roles to the ACL so that every user (requested by, assigned to) are covered. You could use 'snc_internal' for example, but be careful with this, because this gives access to all users if you do not define the script correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you don't want admins to override the ACL, you can uncheck the 'Admin overrides' checkbox.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if this works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Brian&lt;/P&gt;</description>
      <pubDate>Sat, 03 Aug 2024 09:16:43 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/i-want-to-write-a-script-in-acl/m-p/3008234#M525558</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2024-08-03T09:16:43Z</dc:date>
    </item>
    <item>
      <title>Re: I want to write a script in ACL</title>
      <link>https://www.servicenow.com/community/itsm-forum/i-want-to-write-a-script-in-acl/m-p/3008236#M525559</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;you can achieve this requirement as using following code in the ACL script&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV&gt;&lt;STRONG&gt;type = &lt;/STRONG&gt;record&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;operation =&lt;/STRONG&gt; write&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;admin override = &lt;/STRONG&gt;false (unchecked)&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;advanced = t&lt;/STRONG&gt;rue( checked&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;Name &amp;gt; &lt;/STRONG&gt;change request.close_code&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;required role&amp;nbsp;= &lt;/STRONG&gt;(itil/snc_internal) roles already assigned to both ( requester or assigned to).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;Codition script:&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (current.requested_by == gs.getUserID() || current.assigned_to == gs.getUserID() || gs.hasRole('change_manager'))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; answer = &lt;/SPAN&gt;&lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;else&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; answer = &lt;/SPAN&gt;&lt;SPAN&gt;false&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;please mark this as solution accept and helpful.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;thanks and regards&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 03 Aug 2024 09:26:33 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/i-want-to-write-a-script-in-acl/m-p/3008236#M525559</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2024-08-03T09:26:33Z</dc:date>
    </item>
    <item>
      <title>Re: I want to write a script in ACL</title>
      <link>https://www.servicenow.com/community/itsm-forum/i-want-to-write-a-script-in-acl/m-p/3008260#M525561</link>
      <description>&lt;P&gt;I think, you should use hasRoleExactly() method to make sure admins also can't edit the close code field.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;gs.hasRoleExactly("change_manager');&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Aug 2024 10:03:15 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/i-want-to-write-a-script-in-acl/m-p/3008260#M525561</guid>
      <dc:creator>AlpUtkuM</dc:creator>
      <dc:date>2024-08-03T10:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: I want to write a script in ACL</title>
      <link>https://www.servicenow.com/community/itsm-forum/i-want-to-write-a-script-in-acl/m-p/3008386#M525567</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/230256"&gt;@Pooja Khatri&lt;/a&gt;&amp;nbsp;Try this&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var user = gs.getUser();
var userId = user.getID();
var hasChangeManagerRole = user.hasRole('change_manager');
var isRequestedBy = (current.requested_by == userId);
var isAssignedTo = (current.assigned_to == userId);
var isAdmin = user.hasRole('admin');
if (hasChangeManagerRole || isRequestedBy || isAssignedTo) {
    answer = true;
} else if (isAdmin) {
    answer = isRequestedBy || isAssignedTo;
} else {
    answer = false;
}&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 03 Aug 2024 18:22:38 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/i-want-to-write-a-script-in-acl/m-p/3008386#M525567</guid>
      <dc:creator>Sid_Takali</dc:creator>
      <dc:date>2024-08-03T18:22:38Z</dc:date>
    </item>
  </channel>
</rss>

