Create a Button to run a Report

Oliver Strein
Tera Contributor

Hi all,

 

I would like to create a button on a form to run a certain report.
I have the button (ui action) but I'm struggling to get the script to run a certain report / open the report view (in a new tab).

 

Any help would be highly appreciated.

1 ACCEPTED SOLUTION

Chaitali_Vale
Mega Sage
Mega Sage

Hello @Oliver Strein ,

Navigate to System UI -> UI Actions -> New -> Enter Name as "View Report" -> Select table ->
Checked the following checkbox :  
Active 
Show insert
Show update
Form button
List Context Menu
Set the condition : current.isValidRecord()
Add following script : 

// redirect to view report

action.setReturnURL(current);
//action.setRedirectURL("sys_report_template.do?jvar_report_id=" + current.sys_id);
action.setRedirectURL("sys_report_template.do?jvar_report_id=d028d98f470111002ee987e8dee49097&jvar_selected_tab=myReports&jvar_list_order_by=&jvar_list_sort_direction=&sysparm_reportquery=&jvar_search_created_by=&jvar_search_table=incident&jvar_search_report_sys_id=&jvar_report_home_query=&sysparm_use_polaris=true" + current.sys_id); // in this you need to enter the report url


Chaitali_Vale_0-1695802774362.png

Chaitali_Vale_1-1695802802360.png

Chaitali_Vale_3-1695802896539.png

 

Chaitali_Vale_4-1695802921332.png

 

Please mark my solution correct or helpful, if applicable.

Thanks & Regards
Chaitali Vale

 

View solution in original post

2 REPLIES 2

Chaitali_Vale
Mega Sage
Mega Sage

Hello @Oliver Strein ,

Navigate to System UI -> UI Actions -> New -> Enter Name as "View Report" -> Select table ->
Checked the following checkbox :  
Active 
Show insert
Show update
Form button
List Context Menu
Set the condition : current.isValidRecord()
Add following script : 

// redirect to view report

action.setReturnURL(current);
//action.setRedirectURL("sys_report_template.do?jvar_report_id=" + current.sys_id);
action.setRedirectURL("sys_report_template.do?jvar_report_id=d028d98f470111002ee987e8dee49097&jvar_selected_tab=myReports&jvar_list_order_by=&jvar_list_sort_direction=&sysparm_reportquery=&jvar_search_created_by=&jvar_search_table=incident&jvar_search_report_sys_id=&jvar_report_home_query=&sysparm_use_polaris=true" + current.sys_id); // in this you need to enter the report url


Chaitali_Vale_0-1695802774362.png

Chaitali_Vale_1-1695802802360.png

Chaitali_Vale_3-1695802896539.png

 

Chaitali_Vale_4-1695802921332.png

 

Please mark my solution correct or helpful, if applicable.

Thanks & Regards
Chaitali Vale

 

Hi Chaitali_Vale

thanks so much. My users are very happy. And I learned again.

Much appreciated.

 

Thanks and kind regards,

Oliver