<?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: How can I display only current approvers on ticket page of Service Portal? in ServiceNow AI Platform forum</title>
    <link>https://www.servicenow.com/community/servicenow-ai-platform-forum/how-can-i-display-only-current-approvers-on-ticket-page-of/m-p/1106532#M62921</link>
    <description>&lt;P&gt;Can you turn the logic around and create this BR on the sc_req_item table?&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;(function executeRule(current, previous /*null when async*/ ) {

	current.u_current_approvers = '';
	
    var appr = new GlideRecord('sysapproval_approver');
	appr.addQuery('sysapproval',current.getUniqueValue());
	appr.addQuery('state','requested')
    appr.query();
	while(appr.next()){
		current.u_current_approvers += appr.approver.toString() + ', ';
		current.update();
	}

})(current, previous);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 22 Aug 2022 09:02:08 GMT</pubDate>
    <dc:creator>Mark Manders</dc:creator>
    <dc:date>2022-08-22T09:02:08Z</dc:date>
    <item>
      <title>How can I display only current approvers on ticket page of Service Portal?</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-forum/how-can-i-display-only-current-approvers-on-ticket-page-of/m-p/1106529#M62918</link>
      <description>&lt;P&gt;Hi everyone!&lt;/P&gt;
&lt;P&gt;I was referring to this post to try to get the approvers to show up on the Service Portal ticket page.&lt;BR /&gt;&lt;A href="https://community.servicenow.com/community?id=community_question&amp;amp;sys_id=5ff9520bdb518d10019ac2230596198a" target="_blank" rel="noopener noreferrer"&gt;https://community.servicenow.com/community?id=community_question&amp;amp;sys_id=5ff9520bdb518d10019ac2230596198a&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I was able to display the approvers.&lt;BR /&gt;However, if, for example, approval record B is created after approval record A is approved, the approvers for the previous record are still displayed and the approvers for the next record are added to the list.&lt;/P&gt;
&lt;P&gt;In this case, when approval record B is created, we want only that approver to be displayed.&lt;/P&gt;
&lt;P&gt;I have added code to the business rule to initialize the field for display to solve this problem, but it does not work.&lt;/P&gt;
&lt;P&gt;How can I achieve my requirements?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Table Name:&amp;nbsp;&lt;STRONG&gt;sysapproval_approver&lt;/STRONG&gt;&lt;BR /&gt;When: &lt;STRONG&gt;After Insert&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;(function executeRule(current, previous /*null when async*/ ) {

    var gr = new GlideRecord('sc_req_item');
    gr.addQuery('sys_id', current.sysapproval);
    gr.query();

	// Show current approvers on glide_list field "u_current_approvers"
    if (gr.u_current_approvers == '') {
        if (gr.next()) {
            gr.u_current_approvers += ',' + current.approver.toString();
        }

	// Initialize if there is a value in glide_list field "u_current_approvers"
    } else {
        gr.u_current_approvers = '';

        if (gr.next()) {
            gr.u_current_approvers += ',' + current.approver.toString();
        }

    }

    gr.update();

})(current, previous);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Kou&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2022 03:35:13 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-forum/how-can-i-display-only-current-approvers-on-ticket-page-of/m-p/1106529#M62918</guid>
      <dc:creator>Kou1</dc:creator>
      <dc:date>2022-08-22T03:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: How can I display only current approvers on ticket page of Service Portal?</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-forum/how-can-i-display-only-current-approvers-on-ticket-page-of/m-p/1106530#M62919</link>
      <description>&lt;P&gt;I think you should add a condition to the BR to only run on approvals that are 'requested', so you only pick up the actual approvals that are still open and start your BR with clearing the u_current_approvers field, so if there are already users in the array, you remove them.&lt;/P&gt;
&lt;P&gt;&lt;!-- x-tinymce/html-mce_73784805121661146410427 --&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #34495e;"&gt;&lt;EM&gt;If my answer helped you in any way, please then mark it as &lt;STRONG&gt;helpful&lt;/STRONG&gt;. If it resolved the issue, please mark it as&lt;STRONG&gt; correct&lt;/STRONG&gt;.&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #34495e;"&gt;&lt;EM&gt;Mark&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2022 05:51:06 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-forum/how-can-i-display-only-current-approvers-on-ticket-page-of/m-p/1106530#M62919</guid>
      <dc:creator>Mark Manders</dc:creator>
      <dc:date>2022-08-22T05:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: How can I display only current approvers on ticket page of Service Portal?</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-forum/how-can-i-display-only-current-approvers-on-ticket-page-of/m-p/1106531#M62920</link>
      <description>&lt;P&gt;Hi &lt;SN-MENTION class="sn-mention" table="live_profile" sysid="5e0f4fc8db25f7005ed4a851ca9619ad"&gt;@Mark Manders&lt;/SN-MENTION&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I added a conditional expression to pick up only those Approval records that are 'requested', but no improvement was seen.&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;(function executeRule(current, previous /*null when async*/ ) {

    var gr = new GlideRecord('sc_req_item');
    gr.addQuery('sys_id', current.sysapproval);
    gr.query();

	// Only pick up the actual approvals
    if (current.state == 'requested') {
        gr.u_current_approvers == '';

        // Show current approvers on glide_list field "u_current_approvers"
        if (gr.u_current_approvers == '') {
            if (gr.next()) {
                gr.u_current_approvers += ',' + current.approver.toString();
            }
        }

    // Initialize if there is a value in glide_list field "u_current_approvers"
    } else {
        gr.u_current_approvers = '';

        if (gr.next()) {
            gr.u_current_approvers += ',' + current.approver.toString();
        }
    }
    gr.update();

})(current, previous);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Aug 2022 08:14:59 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-forum/how-can-i-display-only-current-approvers-on-ticket-page-of/m-p/1106531#M62920</guid>
      <dc:creator>Kou1</dc:creator>
      <dc:date>2022-08-22T08:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: How can I display only current approvers on ticket page of Service Portal?</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-forum/how-can-i-display-only-current-approvers-on-ticket-page-of/m-p/1106532#M62921</link>
      <description>&lt;P&gt;Can you turn the logic around and create this BR on the sc_req_item table?&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;(function executeRule(current, previous /*null when async*/ ) {

	current.u_current_approvers = '';
	
    var appr = new GlideRecord('sysapproval_approver');
	appr.addQuery('sysapproval',current.getUniqueValue());
	appr.addQuery('state','requested')
    appr.query();
	while(appr.next()){
		current.u_current_approvers += appr.approver.toString() + ', ';
		current.update();
	}

})(current, previous);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Aug 2022 09:02:08 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-forum/how-can-i-display-only-current-approvers-on-ticket-page-of/m-p/1106532#M62921</guid>
      <dc:creator>Mark Manders</dc:creator>
      <dc:date>2022-08-22T09:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: How can I display only current approvers on ticket page of Service Portal?</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-forum/how-can-i-display-only-current-approvers-on-ticket-page-of/m-p/1106533#M62922</link>
      <description>&lt;P&gt;&lt;!-- x-tinymce/html-mce_39771825921661232592445 --&gt;&lt;/P&gt;
&lt;P&gt;Is your issue resolved? If so, please close the question and if any answer &lt;STRONG&gt;helped &lt;/STRONG&gt;or was &lt;STRONG&gt;correct&lt;/STRONG&gt;, mark it as such, since that will help others when looking for the same. If your issue isn’t resolved, please let us know what in the provided answers didn’t work and what you still need assistance with.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Mark&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2022 05:30:11 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-forum/how-can-i-display-only-current-approvers-on-ticket-page-of/m-p/1106533#M62922</guid>
      <dc:creator>Mark Manders</dc:creator>
      <dc:date>2022-08-23T05:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: How can I display only current approvers on ticket page of Service Portal?</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-forum/how-can-i-display-only-current-approvers-on-ticket-page-of/m-p/1106534#M62923</link>
      <description>&lt;P&gt;Hi &lt;SN-MENTION class="sn-mention" table="live_profile" sysid="5e0f4fc8db25f7005ed4a851ca9619ad"&gt;@Mark Manders&lt;/SN-MENTION&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just tried your code and the current approver display works fine!&lt;/P&gt;
&lt;P&gt;However, another problem was uncovered.&lt;BR /&gt;After approving a request, a user with "No Longer Required" status is displayed.&lt;BR /&gt;I have updated the code as follows, but it does not work.&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;(function executeRule(current, previous /*null when async*/ ) {

    current.u_current_approvers = '';

    var appr = new GlideRecord('sysapproval_approver');
    appr.addQuery('sysapproval', current.getUniqueValue());
    appr.addQuery('state', 'requested');
    appr.query();

    while (appr.next()) {
        current.u_current_approvers += ',' + appr.approver.toString();
        current.update();
    }

    if (appr.state == 'approved' || appr.state == 'cancelled' || appr.state == 'not_required') {
        current.u_current_approvers = '';
        current.update();
    }

})(current, previous);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Aug 2022 07:05:32 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-forum/how-can-i-display-only-current-approvers-on-ticket-page-of/m-p/1106534#M62923</guid>
      <dc:creator>Kou1</dc:creator>
      <dc:date>2022-08-23T07:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: How can I display only current approvers on ticket page of Service Portal?</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-forum/how-can-i-display-only-current-approvers-on-ticket-page-of/m-p/1106535#M62924</link>
      <description>&lt;P&gt;That's strange because you are querying only 'requested' approvals. You should not get any 'no longer required' there, because that's also a state on the approval record. What is the trigger on your BR? Can you make make it 'approval = requested' it it's not already?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2022 08:48:00 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-forum/how-can-i-display-only-current-approvers-on-ticket-page-of/m-p/1106535#M62924</guid>
      <dc:creator>Mark Manders</dc:creator>
      <dc:date>2022-08-23T08:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: How can I display only current approvers on ticket page of Service Portal?</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-forum/how-can-i-display-only-current-approvers-on-ticket-page-of/m-p/1106536#M62925</link>
      <description>&lt;P&gt;I agree, but it leaves the approver uncleared, as in the screenshot.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/113766i4915B041E042F743/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My BR trigger is set up this way.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/113772iE076DD954EF837A6/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2022 09:27:04 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-forum/how-can-i-display-only-current-approvers-on-ticket-page-of/m-p/1106536#M62925</guid>
      <dc:creator>Kou1</dc:creator>
      <dc:date>2022-08-23T09:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: How can I display only current approvers on ticket page of Service Portal?</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-forum/how-can-i-display-only-current-approvers-on-ticket-page-of/m-p/1106537#M62926</link>
      <description>&lt;P&gt;The BR now runs after you update the RITM. Can you make it on display? Because if you have a flow creating a first and second approval, your RITM isn't going to update. It stays on awaiting approval.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2022 05:33:49 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-forum/how-can-i-display-only-current-approvers-on-ticket-page-of/m-p/1106537#M62926</guid>
      <dc:creator>Mark Manders</dc:creator>
      <dc:date>2022-08-24T05:33:49Z</dc:date>
    </item>
    <item>
      <title>Re: How can I display only current approvers on ticket page of Service Portal?</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-forum/how-can-i-display-only-current-approvers-on-ticket-page-of/m-p/1106538#M62927</link>
      <description>&lt;P&gt;You are right!&lt;BR /&gt;My requirement was achieved by making the BR trigger asynchronous or before the update.&lt;/P&gt;
&lt;P&gt;Thank you for your kindness and patience!&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 02:44:04 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-forum/how-can-i-display-only-current-approvers-on-ticket-page-of/m-p/1106538#M62927</guid>
      <dc:creator>Kou1</dc:creator>
      <dc:date>2022-08-25T02:44:04Z</dc:date>
    </item>
    <item>
      <title>Re: How can I display only current approvers on ticket page of Service Portal?</title>
      <link>https://www.servicenow.com/community/servicenow-ai-platform-forum/how-can-i-display-only-current-approvers-on-ticket-page-of/m-p/1106539#M62928</link>
      <description>&lt;P&gt;No problem. Glad it worked!&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 05:31:29 GMT</pubDate>
      <guid>https://www.servicenow.com/community/servicenow-ai-platform-forum/how-can-i-display-only-current-approvers-on-ticket-page-of/m-p/1106539#M62928</guid>
      <dc:creator>Mark Manders</dc:creator>
      <dc:date>2022-08-25T05:31:29Z</dc:date>
    </item>
  </channel>
</rss>

