Maximo

Maximo

Come for answers, stay for best practices. All we're missing is you.

 View Only
  • 1.  Send BIRT report output (pdf) file after the save launch on the object

    Posted Mon May 09, 2022 03:03 PM
    Hello,

    I am catering to a requirement that sends the PDF file (report output) generated via BIRT report execution. This BIRT report will be executed after a save launch on one of MBOs.

    I found one example posted "https://a3jgroup.com/automatically-email-vendor-on-approval-of-purchase-order-in-ibm-maximo/" that matches my requirement and I was able to replicate the similar using a small custom automation script which will be registered on the save launch of that MBO. 

    I am not clear how this will run in the background. It refers a cron task titled REORTSCHEDULE. In our environment, I could find that cron task. Do I need to create a new one? If so what are components that I need fill in? 

    Can someone please explain me how the REPORTSCHEDULE cron tasks work in 7.6.1.1? 

    Thanks

    ------------------------------
    Pankaj Bhide
    Computer Systems Engineer
    Berkeley National Laboratory
    Berkeley CA
    ------------------------------

    #AssetandFacilitiesManagement
    #Maximo


  • 2.  RE: Send BIRT report output (pdf) file after the save launch on the object

    Posted Mon May 09, 2022 03:07 PM
    Pankaj,

    The REPORTSCHEDULE cron task has an Access Level of READONLY, which is typically filtered out by default in the Cron Task Setup app (at least in my experience). Clear that search field and it should be listed.

    This is the same Cron Task that gets built when you schedule a report manually from the Run Reports dialog.

    ------------------------------
    Tim Ferrill
    Solutions Consultant
    Intelligent Technology Solutions
    tferrill@webuildits.com
    www.webuildits.com
    @tferrill/@webuildits
    ------------------------------



  • 3.  RE: Send BIRT report output (pdf) file after the save launch on the object

    Posted Mon May 09, 2022 07:24 PM
    Thanks Tim, I could able to locate the cron task.

    Using the logger, I am able to see that the control is reaching until "PRB queueing report". However nothing happens later.
                reportParams = ReportParameterData()
                reportParams.addParameter("paramOrg",  mbo.getString("orgid"))
                reportParams.addParameter("paramSite", mbo.getString("siteid"))
                reportParams.addParameter("paramWO",   mbo.getString("documentnumber"))
           
                myLogger.debug("PRB queueing report..............." +str(reportParams))
                # Queue the Report to Run
                queueManager = ReportQueueService.getQueueService()
                queueManager.queueReport("lbl_wrc_mov_matl_form_birt.rptdesign", "USER",
                            userInfo.getUserName(), strTo, strSubject,
                            strBody, reportParams,
                            locale.getCountry(), locale.getLanguage(),
                            locale.getVariant(), userInfo.getTimeZone().getID(),
                            userInfo.getLangCode(), long(0), userInfo)
               
    1) Is the method "queueManager.queueReport" supposed to create a new cron task instance for running the report? 

    2) As per java docs, it does not return anything (void). Any suggestion on debugging?

    3) The rows in TASKSCHEDULER and CRONTASKHISTORY tables do not show any references to this report.

    4) Do we really need to have any communicate template for this? The reason is - my script is preparing email body, email subject and the recipient email address. Also we may not be interested in keeping log of comm template.




    ------------------------------
    Pankaj Bhide
    Computer Systems Engineer
    Berkeley National Laboratory
    Berkeley CA
    ------------------------------



  • 4.  RE: Send BIRT report output (pdf) file after the save launch on the object

    Posted Mon May 09, 2022 07:36 PM
    Pankaj,

    I'm not sure I can answer all of those questions. I did have a similar use case that I was able to get working, but I wasn't able to get the example from A3J to work for me. I did NOT use a Comm Template.

    Here's a sanitized version of my script:
    from java.util import Calendar
    from java.util import Date
    from psdi.app.report import ReportUtil
    from psdi.server import MXServer
    from psdi.mbo import MboConstants
    
    server = MXServer.getMXServer()
    sysUserInfo = server.getSystemUserInfo()
    sysProps = server.getSystemProperties()
    
    hostname = sysProps.getProperty("mxe.hostname")
    if hostname is None:
      hostname = 'mymaximoserver.com'
    
    reportName = 'mycustomreport.rptdesign'
    appName = 'ASSET'
    emailType = 'attach'
    maximoUrl = 'https://' + hostname
    emailTo = 'test@gmail.com'
    emailSubject = ''
    emailComments = ''
    emailFileType = 'PDF'
    paramDelimeter = '||'
    paramString = ''
    siteField = 'Site Name'
    
    reportParams = {
      'where': '1=1',
      'paramstring': paramString,
      'paramdelimiter': paramDelimeter,
      'appname': 'ASSET',
      'assetnum': mbo.getString('ASSETNUM')
      }
    
    fieldModifiers = MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION_AND_NOACTION
    
    emailSubject = 'Injuries reported during a Damage Assessment'
    emailComments = "<p>A Damage Assessment form has indicated injuries to one or more people.</p><p>The PDF form is attached.</p>"
    
    cal = Calendar.getInstance()
    cal.add(Calendar.SECOND, 60)
    day = cal.getTime()
    
    formSet = mbo.getThisMboSet()
    if formSet is not None:
      locale = formSet.getClientLocale()
      schedule = ReportUtil.convertOnceToSchedule(day,locale, cal.getTimeZone())
      if schedule is not None:
        reportschedset = server.getMboSet("REPORTSCHED", sysUserInfo)
        if reportschedset is not None:
          reportsched = reportschedset.add()
          reportsched.setValue("REPORTNAME", reportName)
          reportsched.setValue("appname", appName)
          reportsched.setValue("USERID", sysUserInfo.getUserName())
          reportsched.setValue("TYPE", "once")
          reportsched.setValue("EMAILTYPE", emailType)
          reportsched.setValue("MAXIMOURL", maximoUrl)
          reportsched.setValue("EMAILUSERS", emailTo)
          reportsched.setValue("EMAILSUBJECT", emailSubject)
          reportsched.setValue("EMAILCOMMENTS", emailComments)
          reportsched.setValue("EMAILFILETYPE", emailFileType)
          reportsched.setValue("COUNTRY", locale.getCountry())
          reportsched.setValue("LANGUAGE", locale.getLanguage())
          reportsched.setValue("VARIANT", locale.getVariant())
          reportsched.setValue("TIMEZONE", formSet.getClientTimeZone().getID())
          reportsched.setValue("LANGCODE", sysUserInfo.getLangCode())
          crontaskdef = reportsched.getMboSet("$parent","crontaskdef","crontaskname='REPORTSCHEDULE'").getMbo(0)
          if crontaskdef is not None:
            crontaskinstset = crontaskdef.getMboSet("CRONTASKINSTANCE")
            if crontaskinstset is not None:
              crontaskinst = crontaskinstset.add(fieldModifiers)
              if crontaskinst is not None:
                d = Date()
                crontaskinstname = str(d.getTime())
                crontaskinst.setValue("CRONTASKNAME", "REPORTSCHEDULE", fieldModifiers)
                crontaskinst.setValue("INSTANCENAME", crontaskinstname, fieldModifiers)
                crontaskinst.setValue("SCHEDULE", schedule, fieldModifiers)
                crontaskinst.setValue("ACTIVE", 1, fieldModifiers)
                crontaskinst.setValue("RUNASUSERID", sysUserInfo.getUserName(), fieldModifiers)
                crontaskinst.setValue("HASLD", 0, fieldModifiers)
                crontaskinst.setValue("AUTOREMOVAL", True, fieldModifiers)
                reportsched.setValue("CRONTASKNAME", crontaskinst.getString("CRONTASKNAME"))
                reportsched.setValue("INSTANCENAME", crontaskinst.getString("INSTANCENAME"))
                cronparamset = crontaskinst.getMboSet("PARAMETER")
                if cronparamset is not None:
                  for p in reportParams.keys():
                    cronparam = cronparamset.add(fieldModifiers)
                    if cronparam is not None:
                      cronparam.setValue("CRONTASKNAME", "REPORTSCHEDULE", fieldModifiers)
                      cronparam.setValue("INSTANCENAME", crontaskinst.getString("INSTANCENAME"), fieldModifiers)
                      cronparam.setValue("PARAMETER", p, fieldModifiers)
                      cronparam.setValue("VALUE", reportParams[p], fieldModifiers)
                  cronparamset.save()
                  reportschedset.save()

    Hopefully this helps.

    ------------------------------
    Tim Ferrill
    Solutions Consultant
    Intelligent Technology Solutions
    tferrill@webuildits.com
    www.webuildits.com
    @tferrill/@webuildits
    ------------------------------



  • 5.  RE: Send BIRT report output (pdf) file after the save launch on the object

    Posted Mon May 09, 2022 08:13 PM
    Thanks Tim. I will surely study your code and let you know if I have any questions.