How about in a relationship?
from psdi.server import MXServer
from psdi.mbo import MboConstants
CUR_LOCID = mbo.getString("LOCATION")
CUR_SITEID = mbo.getString("SITEID")
#Example
#Create relationship - Name: CUR_LOCANCESTOR
#Parent: WORKORDER Child: LOCATIONS
#Where Clause:
#location=:location and siteid=:siteid and exists(select null from locancestor where location = :location and siteid = :siteid and ancestor='SPEC_LOCID')
if(!mbo.getMboSet("CUR_LOCANCESTOR").isEmpty()):
mbo.setValue("WORISK", 3)
------------------------------
Nivin Jacob George Senior Consultant
Senior Consultant
Praxis Solutions
Kuwait
------------------------------
Original Message:
Sent: Thu November 04, 2021 01:19 PM
From: Jason Verly
Subject: Automation Script to do equivalent of "if exists"
I've had a request to set the value on a field on a Work Order if the Location on the WO has a specific ancestor (don't want to use Lochierachy because a location could be a grandchild or more). I got the entire query setup except for the check to see if the Location on the work order exists in the specific location hierarchy.
from psdi.server import MXServerfrom psdi.mbo import MboConstantsCUR_LOCID = mbo.getString("LOCATION")CUR_SITEID = mbo.getString("SITEID")if CUR_SITEID == 'ACME' and exists(select null from locancestor where location = workorder.location and siteid = workorder.siteid and ancestor='SPEC_LOCID') mbo.setValue("WORISK", 3)
My challenge is finding the equivalent of the "if exists" portion in the automation script? Looking for any suggestions. Thanks!
------------------------------
Jason Verly
Reliability Engineering Manager
Agropur US
Le Sueur MN
------------------------------
#AssetandFacilitiesManagement
#Maximo