The web blog http://www.learnsccd.com strives to be a comprehensive guide to SCCD, TADDM, SERVICE NOW and MAXIMO tools. This is a personal site maintained solely by me. I intend to update it regularly.For live updates please follow us on.

Maximo Automation Script-Validate group membership to order consignment items

Maximo Automation Script-Validate group membership to order consignment items

Validate that only certain user groups can order consignment items, in this case, members of Group1, Group2, or Group3.  Note that we are using both the legacy item.outside, and inventory.consignment to validate against.  The variable inventory.consignment is only exposed if the prline is written to a storeroom.  All of the print calls are for debugging at INFO level or above.

Attribute Launch Point: PRCONSIGN
Object: PRLINE
Attribute: ITEMNUM

Variable   Variable Type Binding Type Binding Value        Overridden
b_invconsign IN ATTRIBUTE  INVENTORY.CONSIGNMENT  Y
b_itemoutside IN ATTRIBUTE ITEM.OUTSIDE                  Y

errorgroup: validation
errorkey:        consignmentvalidation
messageid: BMXZZ____E
value: You are not authorized to purchase consignment items.\nPlease contact the Purchasing Department for assistance.
displayid: NO
buttons: "OK?"

Script: (print invoked in debug logging)

from psdi.server import MXServer

s_secgroupset = "'Group1','Group2','Group3'"
b_userBelongsToSecurityGroup = False
s_rem = "*****"

def setError():
global errorkey,errorgroup
errorkey='consignmentvalidation'
errorgroup='validation'
if 1==1:
print s_rem
print s_rem+"b_invconsign = "+str(b_invconsign)
print s_rem+"b_itemoutside = "+str(b_itemoutside)

# check if PRLINE.CONSIGNMENT = 1
if not(b_invconsign == 1 or b_itemoutside == 1):
print s_rem+"Item is not consignment"
if (b_invconsign == 1 or b_itemoutside == 1):
print s_rem+"Enter mboMaxuser routine"
mbosetMaxuser = MXServer.getMXServer().getMboSet("MAXUSER", mbo.getUserInfo())
mbosetMaxuser.setWhere("userid = '" + user + "'")
mbosetMaxuser.reset()
mboMaxuser = mbosetMaxuser.moveFirst()
print s_rem+"mboMaxUSer: "+ str(mboMaxuser)
print s_rem+"Exit mboMaxuser routine"
print s_rem+"Enter mboMaxGroup routine"
print s_rem
if (mboMaxuser is not None):
print s_rem+"Enter mboMaxGroup routine"
mbosetGroupUser = mboMaxuser.getMboSet("GROUPUSER")
mbosetGroupUser.setWhere("groupname in (" + s_secgroupset + ")")
mbosetGroupUser.reset()
print s_rem+"Where Clause: "+str(mbosetGroupUser.getCompleteWhere())
mboMaxGroup = mbosetGroupUser.moveFirst()
if (not mbosetGroupUser.isEmpty()):
b_userBelongsToSecurityGroup = True
print s_rem+"mbosetGroupUser IS NOT EMPTY"
                print s_rem
                print s_rem+"User belongs to security group: "+str(b_userBelongsToSecurityGroup)
                print s_rem
if (mbosetGroupUser.isEmpty()):
print s_rem+"mbosetGroupUser IS EMPTY"
setError()
                print s_rem
                print s_rem+"User belongs to security group: "+str(b_userBelongsToSecurityGroup)
                print s_rem