Maximo Open Forum

 View Only

 Automation script to add additional recipient to Communication Template just before sending email

  • Everything Maximo
Jennifer Johnston's profile image
Jennifer Johnston posted 06-04-2021 17:19
In the receiving app, we have a  field containing the userid of the person an item was delivered to.  I want to send an email to this person using a communication template.  I tried using an automation script to replace the current value of TOLIST with the  ‘Delivered To’ person.  The TOLIST value is set and saved with no error, but the email still goes to the original TOLIST recipient. Does anyone have a method to change the communication template TOLIST just before sending the email?
Biplab Choudhury's profile image
Biplab Choudhury
It would have been good to see the script and more details about the commtemplate.

Here below are the steps to send email of the person:

1. Create Commtemplate and use role for communication template sent to data
2. Create a new role of type 'A set of data related to the record'
3. provided the personid field from receipt object in the role value. Use the same role in the comm template.
4. Write a script which you call te comm template from step and send the receipt mbo into the send message method of the commtemplate.

Example script if found on internet:
ctMboSet = mbo.getMboSet("$commtemp", "COMMTEMPLATE", "TEMPLATEID ='MYCOMMTEMPLATE'")
ctMbo = ctMboSet.getMbo(0)
ctMbo.sendMessage(mbo, mbo)
Prashant Sharma's profile image
Prashant Sharma
Hi Jennifer,

If you specifically want to do manipulation with TO LIST then you need to work with CUstomRoleAdapter class which has a method public String[] evaluateToEmail(MaxRole roleMbo, MboRemote mbo) throws MXException, RemoteException to be overwritten.

Otherwise use the method suggested by Biplab in thread below.

Thanks,
Jennifer Johnston's profile image
Jennifer Johnston
Thank you for your response.  Receiving is not in the drop down for roles,  can it be added? I thought of using the PO, but could not determine how to create a relationship from the PO to the specific receipt record.
Matt McGuire's profile image
Matt McGuire
Hi Jennifer,

I don't know that you need to create an automation script. My understanding of your end state is to send an email to the userid in the 'Delivered To' field.

Assuming that's the case complete the following steps:
  1. Create a role
  2. Set Type to 'A set of data related to the record'
  3. Set Object to 'PO' (my assumption is the deliverto attribute is on the PO object. If that's not the case, insert the attribute's object here)
  4. Set the value to ':deliveredto' (insert your attribute after the colon)
  5. Save the role and add to your Communication Template

With regards to your question about the PO/Receiving relationship, there is no receiving object. The Receiving application is built upon the PO object.

Please reach out if you have any additional questions.

Matt McGuire
Aquitas Solutions
Jennifer Johnston's profile image
Jennifer Johnston
Thank you Matt.  The "Delivered To" field is in the MATRECTRANS table, but this table cannot be used as an object in a Role.  Your statement that the main object of the Receiving app is the PO got me moving in the right direction.  Following your instructions, I created a role against the PO object.  For the value, I entered ":POLINE.MATRECTRANS.deliveredto".   The role was assigned to a communication template.  The communication template is called in an automation script (as identify by Biplab Choudhury in this thread).  This procedure has the desired effect of sending a delivery notice email to the person identified in the MATRECTRANS.DELIVEREDTO field.   Thanks again Matt and Biplab.