Mitchell Moses
Mega Expert

Hi everyone. I had a lot of trouble trying to figure out a way to export a related list records using a UI action on a related list.

The ask was to export records in this particular related only. I started off trying to construct my own Excel sheets to be downloaded and then just exporting the entire record's contents into excel until I found the Detailed Portrait PDF export in the context menu. This prints out a PDF with your current form view and looks great.

 

(and since related lists don't have export OOB) I was able to figure out that you could take the Detailed Portrait context menu code and pass some of your vairiables to get this export to work from a ui action button! 

 

 

find_real_file.png

find_real_file.png

find_real_file.png

 

You can add this to your own UI action on a related list by doing this code:

Onclick: runContextAction()

Condition: RP.isRelatedList()

Script:

function runContextAction() {

	var sysparm_rows = g_list.grandTotalRows;
	var num_rows = parseInt(sysparm_rows);
	var sysparm_query = "change_request.sys_id=" + g_form.getUniqueValue();//add in your own sysparam query here you can get this from the URL when you do your own query 
	var sysparm_view = g_list.view;
	if (num_rows < g_export_warn_threshold) {
		var dialog = new GwtPollDialog(g_list.tableName, sysparm_query, sysparm_rows, sysparm_view, 'unload_pdf+');
		dialog.execute();
		return;
	}
	var dialog = new GwtExportScheduleDialog(g_list.tableName, sysparm_query, sysparm_rows, sysparm_view, 'unload_pdf+');
	dialog.execute();
}

It's as simple as that! 🙂

Comments
Sonam Sinha1
Tera Explorer

Hi Mitchell Moses, 

I am working on creating another context menu, beacsuse I am unable to fetch the images on kb_knowledge while extracting the pdf. Any idea how to achieve it. The context menu is OOTB but I need to have a different menu only for knowledge article.

 

Help! @Mitchell Moses 

 

Le Son
Tera Contributor

Hi Mitchell Moses

Can i custom form of excel?

Community Alums
Not applicable

Have you done any work with this in Workspace?  
I'm getting error when trying to implement Workspace List Action in Client Script:

Error while running Client Script "GlideScopedScript": ReferenceError: GwtPollDialog is not defined

Version history
Last update:
‎09-29-2021 11:44 AM
Updated by: