Original Message:
Sent: 8/6/2024 8:32:00 PM
From: MAX092012
Subject: RE: Pass Report Parameters through automation script
Thank you Matt and Jason. Your solution works in case of list tab however my requirement in the sub tab of a particular application where in the getUserWhere() does not return the expected records selected. Hence I used a temporary table to store the records that are selected and then passed the where clause to the report.
------------------------------
MAX092012
------------------------------
Original Message:
Sent: Wed July 31, 2024 09:37 PM
From: Matt F
Subject: Pass Report Parameters through automation script
Thanks, Jason! I read through your blog and with a few adjustments, I was able to get the script running using the SqlFormat class. Thanks for the tip!
from psdi.mbo import MboConstants, SqlFormatfrom psdi.server import MXServerfrom com.ibm.tivoli.maximo.report.birt.runtime import ReportParameterData# Get the current session, app, and whereclausesession = service.webclientsession()appName = session.getCurrentApp().getApp()currentWhereClause = mbo.getThisMboSet().getUserWhere()# Fetch the report MBOsqlf = SqlFormat(mbo, "reportname = :1 and appname = :2")sqlf.setObject(1, "REPORT", "REPORTNAME", "woprint.rptdesign")sqlf.setObject(2, "REPORT", "APPNAME", appName.upper())reportMboSet = mbo.getMboSet("$REPORTSPI", "REPORT", sqlf.format())reportMboSet.reset()report = reportMboSet.moveFirst()if report is not None: reportnum = str(report.getInt("REPORTNUM")) pageName = "reportd" + reportnum # Create the report parameter data parameterData = ReportParameterData() parameterData.addParameter("where", currentWhereClause) #Load request page session.loadDialog(pageName)
------------------------------
Matt F
Original Message:
Sent: Wed July 31, 2024 03:11 PM
From: Jason VenHuizen
Subject: Pass Report Parameters through automation script
My only comment is a preference to the the psdi.mbo.SqlFormat class for creating where clauses.
https://www.sharptree.io/blog/2022/2022-01-31-sql-format/
from psdi.mbo import MboConstants, SqlFormatfrom psdi.server import MXServerfrom com.ibm.tivoli.maximo.report.birt.runtime import ReportParameterData# Get the current session, app, and whereclausesession = service.webclientsession()appName = session.getCurrentApp().getApp()currentWhereClause = mbo.getThisMboSet().getUserWhere()# Fetch the report MBOsqlf = SqlFormat("reportname = :1 and appname = :2")sqlf.setObject("REPORT", "REPORTNAME", "woprint.rptdesign")sqlf.setObject("REPORT", "APPNAME", appName.upper())reportMboSet = mbo.getMboSet("$REPORTSPI", "REPORT", sqlf.format())reportMboSet.reset()report = reportMboSet.moveFirst()if report is not None: reportnum = str(report.getInt("REPORTNUM")) pageName = "reportd" + reportnum session.loadDialog(pageName) # Create the report parameter data parameterData = ReportParameterData() parameterData.addParameter("where", currentWhereClause)
------------------------------
Jason VenHuizen
https://sharptree.io
https://opqo.io
Original Message:
Sent: Wed July 31, 2024 02:33 PM
From: Matt F
Subject: Pass Report Parameters through automation script
I was able to get this working using the script below with the WO Details report. On the List screen, I had filtered on 3 WO's and received a print out of each one as expected.
from psdi.mbo import MboConstantsfrom psdi.server import MXServerfrom com.ibm.tivoli.maximo.report.birt.runtime import ReportParameterData# Get the current session, app, and whereclausesession = service.webclientsession()appName = session.getCurrentApp().getApp()currentWhereClause = mbo.getThisMboSet().getUserWhere()# Fetch the report MBOreportMboSet = mbo.getMboSet("$REPORTSPI", "REPORT", "REPORTNAME ='woprint.rptdesign' and APPNAME='" + appName.upper() + "'")reportMboSet.reset()report = reportMboSet.moveFirst()if report is not None: reportnum = str(report.getInt("REPORTNUM")) pageName = "reportd" + reportnum session.loadDialog(pageName) # Create the report parameter data parameterData = ReportParameterData() parameterData.addParameter("where", currentWhereClause)
@Jason VenHuizen - any improvements or best practices that you'd recommend to the above? My other thought would be if there's no need to engage with the Request Page dialog, they could utilize the service.invokeMethod and just run the report immediately? But i guess that depends on the use case if there's ever a need to e-mail/schedule it, then using the above should suffice.
Cheers,
------------------------------
Matt F
Original Message:
Sent: Tue July 30, 2024 04:32 PM
From: MAX092012
Subject: Pass Report Parameters through automation script
Hi Bradley,
As mentioned earlier, I'm able to grab the records selected however the only challenge that I'm facing here is to rebuild the where clause and pass it to the report engine. I need to pass the where clause to the birt report viewer which seems to be a challenge as we can do that for direct print or scheduling a report. Below is the script that I'm calling on click of the button and here I'm not sure how to pass the where clause as report parameter,
session=service.webclientsession()
appName=session.getCurrentApp().getApp()
where ="REPORTNAME ='customrpt.rptdesign' and APPNAME='"+appName.upper()+"' "
reportSet = mbo.getMboSet("$REPORTSPI","REPORT",where)
reportSet.reset()
report = reportSet.moveFirst()
if report is not None:
reportnum = str(report.getInt("REPORTNUM"))
pageName = "reportd"+reportnum
session.loadDialog(pageName)
------------------------------
MAX092012
Original Message:
Sent: Tue July 30, 2024 02:30 PM
From: Bradley Downing
Subject: Pass Report Parameters through automation script
Ah! OK use case is clearer now. My view is that if you have the MBO you should be able to grab the record selection from that. Dunno what that might actually be though (w/r/t the element within the MBO.) Also if it is non persistent then that will pose an additional challenge. That is beyond my knowledge. @Steven Shull might know that. But theoretically if you can grab the recrod selection then you can "re-build" the "where" param that is passed to the report.
------------------------------
Bradley K. Downing , MBA
Senior Solution Architect
IBM
Bakersfield
Original Message:
Sent: Mon July 29, 2024 11:40 PM
From: MAX092012
Subject: Pass Report Parameters through automation script
Hi Bradley,
Thank you for your response! The report would be triggered from a sub tab, for example in work order tracking application > actual tab > in the labor sub tab there are 5 labors and we would select 3 labors and click on a button to launch a custom report that would run only for these 3 selected labors . I'm able to run the report by invoking the loadDialog(pageNum) however I'm unable to pass the 3 labors selected, instead the report is running for all the 5 labors. Please note that I'm able to retrieve the 3 labors that are selected however I'm unable to pass them to the report. I'm not sure if there is a way to pass the where clause while invoking the loadDialog.
------------------------------
MAX092012
Original Message:
Sent: Mon July 29, 2024 03:08 PM
From: Bradley Downing
Subject: Pass Report Parameters through automation script
HI!
There are a few ways to launch a report for a given record. You can go into the report application and check the box to register the report to run from the Main page toolbar. This will pass only the current record into the "where clause". No need for an automation script. If you have the report also registered to run from the list page then it will pass all the records listed on the List page (Browser List checkbox enabled) Are you trying to click on the checkbox on the left side to create a subset of listed records and then run report for selected sub records?
Quick update: I just checked this ability for the WOTRACK.RPTDESIGN in MAS 8.11 (Manage 8.7.9) and if in Maxdemo db you filter work orders on Asset like '1143%' then you will get twenty seven work orders. Then scroll to bottom and click on "Select Records". Then pick your desired records (let's say three.). Then click on Report List Icon. You will get three records. Is this what you are trying to accomplish?
------------------------------
Bradley K. Downing , MBA
Senior Solution Architect
IBM
Bakersfield
Original Message:
Sent: Fri July 26, 2024 12:39 AM
From: MAX092012
Subject: Pass Report Parameters through automation script
Hello,
We have a custom report that does not have any report parameters and this report would be launched on click of a button based on the records selected by the user. For example if there are 3 records displayed and user selects the second record then the report should run only for the second record. This selection is based on a non-persistent check box. I'm not sure on how we can pass the MBO to the report during run time. At the moment the report is getting executed for all the 3 records.
I have simply tried to fetch the report from REPORT mbo and invoke loadDialog using action launch point.
------------------------------
MAX092012
------------------------------