Sunday 8 March 2015

Year Comparison using Automation Script

from java.util import Calendar

cal = Calendar.getInstance()
cal.setTime(actcomdateloc)
locactcomyear = cal.get(Calendar.YEAR)
currentyear = Calendar.getInstance().get(Calendar.YEAR);
val = currentyear-locactcomyear
return val
Automation Script to throw warning message for issuing items against asset under warranty:

from java.util import Calendar
from psdi.server import MXServer
from psdi.util import MXApplicationException
if mbo.getOwner().getString('WARRANTYEXPDATE') =='':
 errorgroup = ""  
 errorkey = ""
else:
 if(mbo.getOwner().getDate('warrantyexpdate') >= (Calendar.getInstance().getTime())):
  msgparams = [mbo.getOwner().getString('ASSETNUM')];
  mxae = MXApplicationException("workorder","AssetWarrantyNotice",msgparams)
  mbo.getThisMboSet().addWarning(mxae)



Steps to throw warning message using automation script

Add the line below to the imports:


from psdi.util import MXApplicationException

then add the following:


mxae = MXApplicationException(msggroup, msgkey, msgparams)
mbo.getThisMboSet().addWarning(mxae)


Choose the desired msggroup ,msgkey and pass appropriate value of msgparams