Automatically Email Vendor on Approval of Purchase Order in IBM Maximo

Automate emails to vendors from approved purchase orders in Maximo CMMS

This article will walk an IBM Maximo administrator through the steps necessary to send a purchase order by email to a vendor as an attachment. It is a common requirement by customers to be able to automatically send the purchase order to vendors through email. Some of the benefits of doing this are:

  • Standardize the way that approved purchase orders are communicated to vendors. A common template can be used for the email subject and body, as well as a common workflow for when the communication is sent.
  • Reduce the time taken by procurement agents in generating reports, saving them locally, finding appropriate contact information, and typing up an email.
  • When IBM Maximo sends the email, a copy of the email that was sent is stored in the Communication Log along with the purchase order. If you ever need to know when the email was sent and to whom, the documentation of the email is in IBM Maximo attached directly to the purchase order. No more searching through email to find the communication.

To achieve this, we will deploy an automation script in IBM Maximo that will generate the report and send the email. Before we get to the script, we need to ensure that the following prerequisites are met:

  1. The email address of the vendor should be recorded in the Companies application on the Contacts tab. The script below will use the email address of the Primary Contact (set on the Addresses tab) but can be adjusted to include a larger or more targeted set of email addresses. However, they must be accessible from somewhere in the system by the script.
  2. A Communication Template should be created and activated to be used as the email subject and body of the communication. By default, I’ve named the template POTOVENDOR, but you can name it anything you want and change it in the script.
  3. A BIRT report that represents the purchase order to be sent to vendors. By default, the auto script uses the poprint.rptdesign report that comes with IBM Maximo. This can be changed in the script to a custom report but be sure to match up the report parameters if necessary.

The trigger point for the script below is a status change of the purchase order to APPR. However, this could just as easily be triggered from IBM Maximo workflow, escalations, or other means.

Here is the automation script needed to make this happen:

from com.ibm.tivoli.maximo.report.birt.queue import ReportQueueService
from com.ibm.tivoli.maximo.report.birt.runtime import ReportParameterData
from psdi.mbo import SqlFormat

# Get the current user's information
userInfo = mbo.getUserInfo()
locale = userInfo.getLocale()

# If the PO Vendor does not have a contact with email, then kindly exit
if not mbo.isNull("VENDOR.PRIMARYCONTACT.EMAIL"):
    emailTo = mbo.getString("VENDOR.PRIMARYCONTACT.EMAIL")
    # Append the current user's email address to the chain to ensure delivery
    if userInfo.getEmail() and not userInfo.getEmail() == "":
        emailTo = emailTo + ", " + userInfo.getEmail()
    
    # Create default message subject and body
    # These will be replaced by a communication template if one is found by the code below
    emailSubject = "Purchase Order"
    emailComments = "Please acknowledge receipt of this Purchase Order."
    
    # Change this value to a valid Maximo Communication Template ID
    commTemplateID = "POTOVENDOR"
    
    # Get the communication template
    commTemplateClause = SqlFormat(mbo, "templateid = :1")
    commTemplateClause.setObject(1, "COMMTEMPLATE", "TEMPLATEID", commTemplateID)
    commTemplateSet = mbo.getMboSet("$potovendor", "COMMTEMPLATE", commTemplateClause.format())
    commTemplateMbo = commTemplateSet.getMbo(0)
    if commTemplateMbo:
        # Build the email subject and body from the Communication Template
        sql = SqlFormat(mbo, commTemplateMbo.getString("SUBJECT"))
        sql.setIgnoreUnresolved(True)
        emailSubject = sql.resolveContent()
        sql = SqlFormat(mbo, commTemplateMbo.getString("MESSAGE"))
        sql.setIgnoreUnresolved(True)
        emailComments = sql.resolveContent()
    
    # Build the Report Parameters
    parameterData = ReportParameterData()
    parameterData.addParameter("appname", "PO")
    parameterData.addParameter("paramdelimiter", "")
    parameterData.addParameter("paramstring", "")
    parameterData.addParameter("where", "(po.poid = " + str(mbo.getLong("POID")) + ")")
    
    # Queue the Report to Run
    queueManager = ReportQueueService.getQueueService()
    queueManager.queueReport("poprint.rptdesign", "PO", userInfo.getUserName(), emailTo, emailSubject, emailComments, parameterData, locale.getCountry(), locale.getLanguage(), locale.getVariant(), userInfo.getTimeZone().getID(), userInfo.getLangCode(), long(0), userInfo)

Maximo email with Office 365

I’ve received a lot of questions lately about integrating Maximo with Office 365 for email notification purposes. Let’s take a moment to review the steps necessary to configure this for your organization.

Considerations:

  1. You will need to provide Maximo with a set of credentials that it will use as the “from” email address. All email coming from Maximo will need to utilize this address (more on that below). For the purposes of this tutorial, we are going to assume this configuration.
  2. Alternatively, you can configure a proxy in Office 365 to effectively create a mail relay situation. For example, you might configure a “donotreply@organization.com” address that can be used as the “from” email address that does not need to supply authenticated credentials.

IBM WebSphere Configuration

Office 365 works over SSL. In order for WebSphere to make a proper SSL connection to Office 365, we need to import the Office 365 SSL certificate into WebSphere’s trust store. This will make the connection trusted from WebSphere’s perspective and allow the connection to happen. WebSphere will throw an error if it attempts to make a connection to an untrusted source.

  1. Log into the WebSphere Console as an administrative user.
  2. Navigate to the Security > SSL certificate and key management screen.
  3. Click on the Key stores and certificates link.
  4. Click on the CellDefaultTrustStore link.
  5. Click on the Signer certificates link.
  6. Click on the Retrieve from port button.
  7. Fill out the following required fields:
    1. Host: outlook.office365.com
    2. Port: 993
    3. Alias: outlook.office365.com
  8. Click the Retrieve signer information button.
  9. Click the OK button.
  10. Click the Save to master configuration link.
  11. Once the node synchronization happens, log out of the WebSphere Console.
  12. For this change to take effect, the IBM-related Windows Services will need to be restarted (all Node Agents, the Cell Manager, and the HTTP Server).

Maximo System Properties

The next step is to configure System Properties within Maximo.

  1. Log into Maximo as an administrative user.
  2. Navigate to the System Configuration > Platform Configuration > System Properties application.
  3. Set the mail.smtp.host property to smtp.office365.com
  4. Set the mail.smtp.starttls.enable property to true
  5. Set the mail.smtp.ssl.enable property to false if it is not already false (default is false)
  6. Set the mxe.smtp.user property to the email address you wish all Maximo email notifications to come from (e.g. alex@a3jgroup.com).
  7. Set the mxe.smtp.password property to the Office 365 password for the above user. Please note that it’s also a good idea to check the Masked? checkbox for this property in order to keep the password value hidden in the Maximo user interface.
  8. Click the New Row button to create a new System Property. Fill out the following fields:
    1. Property Name: mail.smtp.port
    2. Description: Port number that the SMTP mail server listens on
    3. Global Value: 587
  9. Click the Save button.
  10. Check the box next to each of the properties above that you had to edit. Then in the Common Actions menu, click the Live Refresh button.
  11. Click the OK button.

Maximo Communication Templates

Each of the Communication Templates in the system must now have the Send From email address set to the same email address that was used to populate the mxe.smtp.user System Property.

 

Maximo Scheduled Reports

You may want to schedule reports to run from Maximo to be emailed to users or groups. Like all other email, the Send From address has to be the value that you configured in the mxe.smtp.user System Property. Unfortunately when Maximo schedules a report to be emailed, it uses the email address from the user that created the report schedule as the Send From address. This will cause most scheduled reports to fail.

The least intrusive solution that I’ve come up with is to create a user that has the same email address that was used to populate the mxe.smtp.user System Property, and then create an automation script to change the user at runtime of the scheduled report. This will allow the system to send scheduled reports via email.

  1. Ensure that you have a user account that has the same email address that was used to populate the mxe.smtp.user System Property.
  2. Navigate to the System Configuration > Platform Configuration > Automation Scripts application.
  3. From the More Actions menu, choose the Create > Script with Object Launch Point option.
  4. In the ensuing dialog, Create Script with Object Launch Point: Step 1 of 3, fill out the following fields:
    1. Launch Point: REPORTRUNQUEUE_LP
    2. Description: Report Run Queue Launch Point
    3. Object: REPORTRUNQUEUE
    4. Active: Yes
    5. Events: Save
    6. Save: Add and Before Save (see screenshot)
    7. Script: New
  5. Click the Next button.
  6. In the next step, Create Script with Object Launch Point: Step 2 of 3, fill out the following fields:
    1. Script: REPORTRUNQUEUE_SCRIPT
    2. Description: Report Run Queue Script
    3. Script Language: python
  7. Click the Next button.
  8. In the next step, Create Script with Object Launch Point: Step 3 of 3, fill out the following fields:
    1. Source Code:
from psdi.mbo import MboConstants mbo.setValue("USERID", "AWALTER", MboConstants.NOACCESSCHECK)

Be sure to substitute the User ID of your user for the AWALTER text in the example above. Click the Create button and you’re set!

That should enable you to utilize Office 365 as your email solution from Maximo. Please feel free to leave comments below.