Get Approval History or Details from Custom Table

Mark52
Tera Contributor

Hi I currently have 2 custom table that is extended from task. I want to display the approval history of approval sequence either via related list or chart within the form of the travel booking or any suggestions will also be ok. 

Table Names:

1. Travel Booking

2. Approval Sequence

Scenario:

1. Create Travel booking Details

2. From the newly created travel booking, create approval sequence where user will input sequence of approval (e.g. 1-10) then input the approvers via list for approvals of approver.

9 REPLIES 9

Hello @mark

Yes you can do it very easily.

1.Create a travel booking record.

2.Create Approval record on Approval sequence table manually.(I hope on Approval sequence record you are also storing travel booking ID)

3.Create a worlflow. with condition state is approval.

In workflow drag a Group Approval activity.

Click on advanced to write the code.

The code is.

var grapp=new GlideRecord('approval_sequence_table_name');

grapp.addQuery('tickect_booking_id_field_name which is on approval sequence table',current.sys_id);

grapp.query();

while(grapp.next())

{

   answer.push(grapp.user.sys_id);//hope user is field on approval sequence table which stores the sys_id of user whose approval is required

}

Above code will send approval to all the users who has that particular  tucket booking id reference.

Please keep posted

Regards

Yash Agrawal

Hi @Yash Agrawal,

Thanks for the code above its working.

 

would you know a way for me to be able to get the details of the approval of users. please see screenshot below. to be displayed at the travel booking form or related list.

find_real_file.png

Thank and Regards,

Mark

 

Hi Mark,

If you are on portal , then follow this link to show approval history with good UI,

https://community.servicenow.com/community?id=community_question&sys_id=174ad251db98b74423f4a345ca96...

Regards
Deepen shah
aavenir.com

Yes Mark,

I would like to help you.But please tell me that from the above shared scrrenshot 

Fields:- sequence,Approver,state,comment,date approved are all this field available on "Approval sequence" table.

If Yes,then we can bring all the above mentioned fields details on travel booking form,in the form of realted list.

Regards

Yash Agrawal

Hi @Yash Agrawal,

 

Yes the fields is available on the approval sequence but the one thing I wasn't able to show was comments.

 

would it also work if the approvers are in a list? (e.g. Sequence 1 Approver has 4)

Regards,

Mark