Maximo

 View Only

 How can we pass Parameters dynamically from Automation Script to run a Report in MAS MANAGE

Rakesh Mannam's profile image
Rakesh Mannam posted Wed June 25, 2025 03:52 AM

Dear All,

Good Day!

I hope this message finds you well.
I have a requirement in Maximo where the user would like to have a Print icon/button available in each row of a child table.

When the user clicks the Print icon, it should open a report that displays information related to that specific row.

Currently, we are using a script to open the report dialog on clicking the Print icon. I would appreciate your guidance or suggestions on how to properly implement this functionality, especially ensuring that the correct row-specific data is passed to the report.

Looking forward to your valuable inputs.

Thank you in advance for your support!

from psdi.webclient.system.session import WebClientSession;
from psdi.mbo import SqlFormat;

wcs = service.webclientsession()

 

sqf = SqlFormat(mbo, "APPNAME='PLUSGPTW' AND REPORTNAME=:2") 
sqf.setObject(2, "REPORT", "REPORTNAME", "PIPP_Isolation_List1.rptdesign")
where = sqf.format()

reportSet = mbo.getMboSet("$REPORTSPI","REPORT",where) 
#Set the set as disposable, we're not changing the report just reading it 
reportSet.setFlag(39L,True) 
reportSet.reset()

report = reportSet.moveFirst() 
reportnum = str(report.getInt("REPORTNUM")) 
pageName = "reportd"+reportnum 
wcs.loadDialog(pageName) 
reportSet.close()
#wcs.showMessageBox("PRINT", "STICKER", ["Updated target finish for PM-generated work orders."])

Johann Rumpl's profile image
Johann Rumpl IBM Champion

Hi Rakesh,

A colleague of mine had such a requirement way back, when Java Classes were still the "weapon" of choice to tackle similar challenges. He allowed me to share a method out of a bean class. It should be possible to translate that into an action script. Of course, not 1:1 but I'm sure you'll find the approach on how to handover parameters and open Report dialogues interesting. Here's his solution based on an Asset report:

public int runreport_from_line() throws MXException, RemoteException {
		MXSession s = getMXSession();
		MboSetRemote reportSet = s.getMboSet("REPORT");
		DataBean assets = app.getDataBean("massmove_PlanMassSwapTable");
		MboRemote mboAsset = assets.getMbo(assets.getCurrentRow());
		String assetnum = mboAsset.getString("ASSETNUM");
		String siteid = mboAsset.getString("SITEID");
		String orgid = mboAsset.getString("ORGID");
		String rptName = "assetdata.rptdesign";
		String whereClause = "ASSET.ASSETNUM='" + assetnum + "' AND ASSET.SITEID='" + siteid + "' AND ASSET.ORGID='" + orgid + "'";
		String appName = "ASSET";
		reportSet.setQbe("appname", appName);
		reportSet.setQbe("reportname", rptName);
		reportSet.setQbeExactMatch(true);
		reportSet.reset();
		if (reportSet.count() == 0) {
			Object[] params = { rptName };
			this.clientSession.showMessageBox(this.clientSession.getCurrentEvent(), "reports", "noxml", params);
			return 1;
		}
		MboRemote reportRec = reportSet.getMbo(0);
		Integer rptNum = Integer.valueOf(reportRec.getInt("reportnum"));
 
		String pageName = new StringBuilder().append("reportd").append(rptNum).toString();
		if (this.clientSession.findDialog(pageName) == null) {
			Object[] params = { pageName };
			this.clientSession.showMessageBox(this.clientSession.getCurrentEvent(), "reports", "noxml", params);
			return 1;
		}
		this.clientSession.loadDialog(pageName);
		Hashtable<String, Object> reportInfo = new Hashtable<String, Object>();
		reportInfo.put("reportnumber", rptNum);
		reportInfo.put("whereclause", whereClause);
		reportInfo.put("username", this.clientSession.getUserInfo().getUserName());
		reportInfo.put("quickprinttype", "QL"); //QL: Web-Ansicht
		reportInfo.put("qpnoprompt", "true");
		this.clientSession
				.handleEvent(new WebClientEvent("requestreportrun", pageName, reportInfo, this.clientSession));
		return 1;
	}

As you can see the first section tries to find the internal REPORTNUM which is used for the requestpage dialog. The second section shows how to put the parameters for the report together before it is executed using the requestreportrun event.

I hope this helps, even if it is not a ready-to-use copy+paste solution.

cheers

Johann