• 1 reply
  • Latest Post - ‏2009-07-21T00:23:22Z by Josh.Hidley
4 Posts

Pinned topic BIRT: How to get the maxuser / maximo username who requested the report?

‏2009-07-17T17:53:38Z |
I need to filter my report's data based on the Maximo user who requested the report. Specifically, I need to show only data which is related to the site the user is in.

I know how to do this if I could get the maxuser who requested the report. Is there a way to reliably get this?

I've figured out how to get it some of the time. The following code works when a report is requested for Immediate printing, but not if the report is scheduled and emailed.

var maxuser = reportContext.getHttpServletRequest().getParameter(

The problem is that if it is scheduled and emailed then getHttpServletRequest() returns null (which makes sense).

Any ideas would be greatly appreciated.



Maximo 7.1
BIRT 2.1.2
Updated on 2009-07-21T00:23:22Z at 2009-07-21T00:23:22Z by Josh.Hidley
  • Josh.Hidley
    4 Posts

    BIRT: How to get the maxuser / maximo username who requested the report?

    Answering my own question: The problem is that the MAXUSER is available from the HttpServletRequest() when a report is run for Immediate printing, but if it's run "At this Time..." or Recurring, then you have to get it from the REPORTJOB table. One solution won't work for both situations.

    You can put the following code into your dataset's Open method and call it to return the MAXUSER who is requesting the report.

    function getUserName(dataSourceName) {
    var userName = null;
    var hsr = reportContext.getHttpServletRequest();

    if(hsr != null) {
    var paramString = hsr.getParameter("parmParameterString");
    // Just for debugging in Eclipse...
    if(paramString == null)
    paramString = "MaximoUserID=george||locale=en_US||mroYes=Y||mroNo=N||rsseAlias=null||multiServer=||reportDesc=PHYSICAL INVENTORY - Missing Physical Counts - NSN Sequence||MaximoUserID=george2||";

    var paramDelimiter = hsr.getParameter("parmParameterStringDelimiter");
    // Just for debugging in Eclipse...
    if(paramDelimiter == null)
    paramDelimiter = "||";

    var key = "MaximoUserID=";

    // These come out of getPrameter as objects and don't play well with string manipulation functions unless casted.
    paramString = String(paramString);
    paramDelimiter = String(paramDelimiter);

    var start = paramString.lastIndexOf(key) + key.length;
    if(start < 0)
    return null;

    var len = paramString.indexOf(paramDelimiter, start);
    if(len < 0)
    len = paramString.length;

    userName = paramString.slice(start, len);

    if(userName == null || userName == "") {
    var reportJobId = mxReportScriptContext.getMXReportContext().get("REPORTJOBID");
    if(reportJobId != null) {
    var reportJobDS = MXReportDataSetProvider.create(dataSourceName, "reportJobDS");;
    reportJobDS.setQueryParameterValue(1, reportJobId);

    userName = reportJobDS.getString("USERID");


    return userName;

    You can call this function with the following code:
    var myUserName = getUserName(this.getDataSource().getName());

    In my other post, I mentioned an unreliable way way to get the MAXUSER when a report is called for Immediate printing. The following didn't work reliably for me. I'm not sure why. Use the method above instead.

    // The following is unreliable! Parse it out of parmParameterString instead.

    Also note that when this is called for Immediate printing, the user name seems to come back in lower-case even if that's not the correct case in MAXUSERS. If you're using a case-sensitive DB (Oracle's default), take that into consideration if you're using it in queries.

    I hope this helps,