How to created related attachment related list on change request table that should contain the attachment attached on approval request

rupali18
Kilo Contributor

I want to create the related list(Relationship) on change table as approval-attachment and it should shows the attachments attached while approving and rejecting the change request. 




1 ACCEPTED SOLUTION

this worked for me

CHG -> has 1 file

Approval record has 1 file

Total 2 records shown in related list

(function refineQuery(current, parent) {

	// Add your code here, such as current.addQuery(field, value);

	// get the approval records for this CHG
	var app = [];
	var gr = new GlideRecord("sysapproval_approver");
	gr.addQuery("sysapproval", parent.getUniqueValue());
	gr.addQuery("source_table", "change_request");
	gr.query();
	while(gr.next()) {
		app.push(gr.getUniqueValue());
	}

	app.push(parent.sys_id.toString());
	current.addQuery("table_sys_id" ,"IN", app.toString());

})(current, parent);

find_real_file.png

find_real_file.png

 

find_real_file.png

Please mark my response as correct and close the thread

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

16 REPLIES 16

screenshot:

 

find_real_file.png

Please use the script I shared and share me the update.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankush,
Still it is not working. I attached the file on approval record but still in related list there is no record.

Hi,

can you share your script and configuration?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

this worked for me

CHG -> has 1 file

Approval record has 1 file

Total 2 records shown in related list

(function refineQuery(current, parent) {

	// Add your code here, such as current.addQuery(field, value);

	// get the approval records for this CHG
	var app = [];
	var gr = new GlideRecord("sysapproval_approver");
	gr.addQuery("sysapproval", parent.getUniqueValue());
	gr.addQuery("source_table", "change_request");
	gr.query();
	while(gr.next()) {
		app.push(gr.getUniqueValue());
	}

	app.push(parent.sys_id.toString());
	current.addQuery("table_sys_id" ,"IN", app.toString());

})(current, parent);

find_real_file.png

find_real_file.png

 

find_real_file.png

Please mark my response as correct and close the thread

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader