Hi Team,
I have an requirement like this: Email(s) should be triggered to vendor once the Work Order status is moved to DESPATCHED and Vendors can have multiple contacts and emails,the email template will be based on the jobplan.
Here is my code:
----------------------
from psdi.mbo import MboConstants
from psdi.server import MXServer
if mbo.isModified("status") and mbo.getString("status") == "DESPATCHED":
vendor=mbo.getString("VENDOR")
whereClause="COMPANY='"+ vendor +"'"
companiesSet=mbo.getMboSet("$WO_VENDOR",'COMPANIES',whereClause)
whreClause="COMPANY='"+ vendor +"'"
compcontactSet=mbo.getMboSet("$WO_CONTACT",'COMPCONTACT',whreClause)
for i in range(0,compcontactSet.count()):
email=compcontactSet.getMbo(i).getString("EMAIL")
if email is not None:
jpnum=mbo.getString("JPNUM")
wherclause="KA_JPNUM='"+ jpnum +"'"
commtemplateSet = mbo.getMboSet("$commtemp","COMMTEMPLATE",wherclause)
templateid=commtemplateSet.getMbo(0).getString("TEMPLATEID")
commtemplatesendtoSet=MXServer.getMXServer().getMboSet("COMMTMPLTSENDTO",MXServer.getMXServer().getSystemUserInfo())
newcommtmplt=commtemplatesendtoSet.add()
if newcommtmplt is not None:
newcommtmplt.setValue("TEMPLATEID",templateid)
newcommtmplt.setValue("TYPE","EMAIL")
newcommtmplt.setValue("SENDTO","1")
newcommtmplt.setValue("SENDTOVALUE",email,MboConstants.NOACCESSCHECK)
commtemplatesendtoSet.save()
commtemplateSet.getMbo(0).sendMessage(mbo,mbo)
I am unable to change the status of work order when the script is active.It was displaying an system message :
owner#NoOwnerFound.
Can anyone help me on this .
Thanks in Advance.
Regards,
Anuja.
------------------------------
Anuja Dhanekula
------------------------------
#AssetandFacilitiesManagement#Maximo#MaximoIntegrationandScripting