How to display Approver name of RITM in Service Portal

Byron Plant
Tera Contributor

Hi everyone!

We've been doing a lot of changes in our Service Portal and one of these is to display the approver name of the RITM so that users without ITIL role can see who's the approver of their RITM.

find_real_file.png


This can be found on sp_instance_table. I tried looking if there's an APPROVER field for this configuration but I don't see one. Is it possible to add the name of Approver for this enhancement?

find_real_file.png

1 ACCEPTED SOLUTION

shloke04
Kilo Patron

Hi @Byron Plant 

Sure will try to assist you here. 

First thing to understand why you are not able to directly select Approver Name in instance option is because Approvals resides in a Different table named as "sysapproval_approver".

So in order to Include Approver name as well, you need to follow below steps:

1) Create a List Type field on Requested Item record and refer it to User Table as shown below:

find_real_file.png

Now write a Business Rule on Approval Table that when ever a approval record is generated for an Requested Item then the field which we have created above will be updated with Name of Approver as show below:

BR Details:

Table Name: sysapproval_approver

When: After Insert

Condition of BR: Approval For-->Task-->Task Type is sc_req_item

Script:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	
	var gr = new GlideRecord('sc_req_item');
	gr.addQuery('sys_id',current.sysapproval);
	gr.query();
	if(gr.next()){
		
		gr.u_approver_name = gr.u_approver_name + ',' + current.approver.toString();
		gr.update();
	}
	

})(current, previous);

find_real_file.png

Now the widget which you have shown is a Simple List widget where I believe you have configured your Widget instance Option to display RITM columns.

Now you need to go to the same instance record as you have mention in your screenshot above and add the field named as "Approver Name" which will show you the Approver Name in your portal view as needed.

find_real_file.png

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

 

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

28 REPLIES 28

Hi @Irene M 

To answer your query, below are my inputs:

1) Yes, you can limit it to one Approver Name only. You just need to update your Business Rule as below:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	
	var gr = new GlideRecord('sc_req_item');
	gr.addQuery('sys_id',current.sysapproval);
	gr.query();
gr.setLimit(1);
	if(gr.next()){
		
		gr.u_approver_name = gr.u_approver_name + ',' + current.approver.toString();
		gr.update();
	}
	

})(current, previous);

 

For your second query below:

"

Also, our system allows approver change. Especially if the current approver is unavailable, we can manually add a different user to act as approver. However, when I tried changing the approver of the RITM, the previous approver was not deleted on the Portal instead it duplicates (see screenshot below)"

You need to write another Business Rule on your Change Request table which will update the Approver field and re calculate the correct value when you insert a manual approval

This will solve your duplicate issue which is happening now

Regards,

Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Irene M
Tera Contributor

Thank you so much for responding Mr. @shloke04 however I am confused regarding your answer to my 2nd query. Why do is it that I need to write another Business Rule on CHANGE REQUEST Table? why not on sc_req_item table? also, can you help me with the Business Rule as well for the 2nd Query? 

Irene M
Tera Contributor

Thank you so much for responding Mr. @shloke04 however I am confused regarding your answer to my 2nd query. Why do I need to write another Business Rule on CHANGE REQUEST Table? why not on sc_req_item table? also, can you help me with the Business Rule as well for the 2nd Query? 

Irene M
Tera Contributor

Thank you so much for responding Mr. @shloke04 

For my 1st query, I copied the script you provided but it didn't work. I still see multiple approver names on the Service Portal.

For my 2nd query, I am confused as to why I need to write another Business Rule on CHANGE REQUEST Table and not on sc_req_item table? Also, can you help me with the Business Rule as well for the 2nd Query? 

Hi @Irene M 

I would suggest to create a new thread for your query, as this might get lost in between two parallel conversation between you and Byron.

To answer your question, yes you would need to write it on Change Request as both are separate table and need to be queried separately.

Please create a new thread and tag me , I can assist you with your pending queries there.

Regards,

Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke