Skip to content

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)

Share This

Related Posts

ibm_mxmobile_maximo mobile_app_application_suite_report_maintenance_reliability_industry_4_work_order_enterprise_asset_management_inventory_perform_count_log_time_create_meter_reading_shipping_and_recieving_mobility_admin_service_request_issue_parts_material_approve_task_job_plan_software_upgrade
MxMobile Update May 2023 Release
As an IBM Maximo mobile solution provider, A3J Group consistently improves the functionality and features...
integration-trobleshooting-IBM-Maximo-A3J-Group-Consulting-e1636065766665
Workflow Delegates
Pretend you are going to take a real vacation, two weeks in Spain with no work laptop. You have planned...
ibm_mxmobile_maximo mobile_app_application_suite_report_maintenance_reliability_industry_4_work_order_enterprise_asset_management_inventory_perform_count_log_time_create_meter_reading_shipping_and_recieving_mobility_admin_service_request_issue_parts_material_approve_task_job_plan_software_upgrade
MxMobile Update April 2023 Release
A3J Group is happy to announce the latest MxMobile releases below. The releases will be available on...

7 Responses

7 Comments

  1. Hi Alex, I am trying to implement this as we have a request for it. Everything appears to work and I see it in the reportrunparam and reportrunqueue tables but nothing ever gets emailed.

    • Ultimately the email will be sent from the REPORTSCHEDULE cron task, even though it will be queued to run immediately. Make sure that Admin Mode is off and that the cron task is able to run (e.g. check the mxe.crontask.donotrun and mxe.crontask.dorun variables). Also, check the report itself and/or the parameters that you are passing to it. Hope that helps.

  2. I’m embarrassed to ask, but some vendors still want to use fax. How do you handle this?

    • There are some good email-to-fax or text-to-fax services out there. Haven’t tried them myself, but those would likely be your best option.

  3. Hi Alex,

    Works perfect for me. Great stuff.
    A question: Is it possible to open an outlook mail for preview?
    Sometime you would need to add or modify the participants list or add special notes
    to the template before it’s being send to the vendor.

  4. Hi Alex,

    Is that the entire Automation Script above? I don’t see a vertical scroll bar and the last line I see starts with “queueManager.queueReport(“.

    I can see how you’re retrieving the CommTemplate but I don’t see how you’re creating a CommLog or how the report is being attached to the CommLog.

    Thanks.

  5. I have run this script and I can see the email with a report. But , the communication log of PO can’t be created. So, Could you please tell me which part of script is used to create the communication logs?
    thanks,


Add a Comment