Topic
  • 10 replies
  • Latest Post - ‏2013-06-17T13:42:06Z by Peter_Jung
SystemAdmin
SystemAdmin
5842 Posts

Pinned topic How to get Maximo user in BIRT

‏2010-04-12T18:48:19Z |
Hello All,
Any buddy know how to get the maximo user that running the repport in BIRT.
I am developing a BIRT report and I need to display the User (First Name + Last Name ) in the repport.
Thanks for your help

Mike
Updated on 2012-08-21T18:20:26Z at 2012-08-21T18:20:26Z by BeethovenLira
  • HD-Ryder
    HD-Ryder
    8 Posts

    Re: How to get Maximo user in BIRT

    ‏2010-04-12T20:08:11Z  
    Your SQL query needs to have a JOIN to the PERSON table. From there, I general use person.displayname, which will allow you to sort on last name. However, if your business requirements demand First Name + Last Name, then you could concatenate person.firstname + person.lastname.

    Use the GUI interface to find your values, and remember: ALT+F1 is your friend!
  • SystemAdmin
    SystemAdmin
    5842 Posts

    Re: How to get Maximo user in BIRT

    ‏2010-04-13T18:57:39Z  
    • HD-Ryder
    • ‏2010-04-12T20:08:11Z
    Your SQL query needs to have a JOIN to the PERSON table. From there, I general use person.displayname, which will allow you to sort on last name. However, if your business requirements demand First Name + Last Name, then you could concatenate person.firstname + person.lastname.

    Use the GUI interface to find your values, and remember: ALT+F1 is your friend!
    Thanks Bro for your answer,
    Yes you right I can do this if a have the personID in the object.
    The problem that I have I need to get the personUserId that running the report to do the left outer join.
    Example:
    if User_A run the report sow I need to get the personID for the user User_A and if User_B run the report sow I need to get the personID for the user User_B

    Any idea??

    Thanks for your time and have a good day
  • SystemAdmin
    SystemAdmin
    5842 Posts

    Re: How to get Maximo user in BIRT

    ‏2010-04-14T15:15:40Z  
    Thanks Bro for your answer,
    Yes you right I can do this if a have the personID in the object.
    The problem that I have I need to get the personUserId that running the report to do the left outer join.
    Example:
    if User_A run the report sow I need to get the personID for the user User_A and if User_B run the report sow I need to get the personID for the user User_B

    Any idea??

    Thanks for your time and have a good day
    Hi,

    get Servlet request object from reportcontext, and get the username paramater from the request object.

    Cheers,
    Siva
  • mirws
    mirws
    2 Posts

    Re: How to get Maximo user in BIRT

    ‏2010-04-15T05:47:05Z  
    Hi.. try to use this function, I found this on the web. you can put the code in Dataset Open event

    function getUserName(dataSourceName) {
    //var dataSourceName = receiptdsname;
    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.open();
    var sql = "SELECT USERID FROM REPORTJOB WHERE REPORTJOBID = ?";
    reportJobDS.setQuery(sql);
    reportJobDS.setQueryParameterValue(1, reportJobId);

    if(reportJobDS.fetch())
    userName = reportJobDS.getString("USERID");

    reportJobDS.close();
    }
    }

    return userName;
    }
  • SystemAdmin
    SystemAdmin
    5842 Posts

    Re: How to get Maximo user in BIRT

    ‏2010-04-15T12:49:40Z  
    Hi,

    get Servlet request object from reportcontext, and get the username paramater from the request object.

    Cheers,
    Siva
    Salut SivaG,
    Please can you send me the code line to get the username parameter from the request object and in witch script you put it (Open, fetch, ...???)
    Have a good day
  • SystemAdmin
    SystemAdmin
    5842 Posts

    Re: How to get Maximo user in BIRT

    ‏2010-04-15T12:52:15Z  
    • mirws
    • ‏2010-04-15T05:47:05Z
    Hi.. try to use this function, I found this on the web. you can put the code in Dataset Open event

    function getUserName(dataSourceName) {
    //var dataSourceName = receiptdsname;
    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.open();
    var sql = "SELECT USERID FROM REPORTJOB WHERE REPORTJOBID = ?";
    reportJobDS.setQuery(sql);
    reportJobDS.setQueryParameterValue(1, reportJobId);

    if(reportJobDS.fetch())
    userName = reportJobDS.getString("USERID");

    reportJobDS.close();
    }
    }

    return userName;
    }
    hello mirws,
    I try this code but it dosn`t work.
    The code try to select from the REPORTJOB object that it dosn`t exist in maximo (var sql = "SELECT USERID FROM REPORTJOB WHERE REPORTJOBID = ?";
    ) any idea about this object???
  • SystemAdmin
    SystemAdmin
    5842 Posts

    Re: How to get Maximo user in BIRT

    ‏2010-04-15T22:19:22Z  
    Salut SivaG,
    Please can you send me the code line to get the username parameter from the request object and in witch script you put it (Open, fetch, ...???)
    Have a good day
    Hi

    Use the following code in "initialize" method
    req = reportContext.getHttpServletRequest();

    if(req != null){
    user = req.getParameter("userName");
    reportContext.setPersistentGlobalVariable("user",user );

    then you can use this variable user in report...

    Note: i wrote this code on the fly.. check the syntax of methods properly...

    Cheers,
    Siva
  • SystemAdmin
    SystemAdmin
    5842 Posts

    Re: How to get Maximo user in BIRT

    ‏2010-04-16T14:26:48Z  
    Hi

    Use the following code in "initialize" method
    req = reportContext.getHttpServletRequest();

    if(req != null){
    user = req.getParameter("userName");
    reportContext.setPersistentGlobalVariable("user",user );

    then you can use this variable user in report...

    Note: i wrote this code on the fly.. check the syntax of methods properly...

    Cheers,
    Siva
    Hello SivaG,
    Thanks allot for your time and your help.
    It is work very good.
    I really appreciate your help.
    Have a great day
  • BeethovenLira
    BeethovenLira
    5 Posts

    Re: How to get Maximo user in BIRT

    ‏2012-08-21T18:20:26Z  
    Hi

    Use the following code in "initialize" method
    req = reportContext.getHttpServletRequest();

    if(req != null){
    user = req.getParameter("userName");
    reportContext.setPersistentGlobalVariable("user",user );

    then you can use this variable user in report...

    Note: i wrote this code on the fly.. check the syntax of methods properly...

    Cheers,
    Siva
    very good solution!
  • Peter_Jung
    Peter_Jung
    21 Posts

    Re: How to get Maximo user in BIRT

    ‏2013-06-17T13:42:06Z  
    hello mirws,
    I try this code but it dosn`t work.
    The code try to select from the REPORTJOB object that it dosn`t exist in maximo (var sql = "SELECT USERID FROM REPORTJOB WHERE REPORTJOBID = ?";
    ) any idea about this object???

    We have a MX 7.1-installation where the above code - why ever - works. But with MX 7.5 it doesn't, so the shorter solution from above (3 or 4 lines) is better, it works with MX 7.1 and MX 7.5 (and it's nice and short!).