Hi all,
I am working on customization for application labor reporting(Mobile). the requirement is,
- while approving labor transaction we have to check its projectid and taskid and throw an error if it's projectid and taskid is having specific value
after a long working session, finally it is working to replace the default tool bar action "APPRLABOR".
i created an action script and executing that action script through signature option.,
the script is
############################################################################################################################
# Script Name : APPRLABOR1
# Launch Point : (Action)
# Launch point type : Action Launch Point
# Description : Controls LABTRANS approval only on LABREPMOB(Labor Reporting (Mobile EL)) application
#################################################################################################################################################################
# Developer Version Date Remarks
#----------------------------------------------------------------------------------------------------------------------------------------------------------------
# Karthik Krishnamurthy 0.1 19-Mar-2026
#
#################################################################################################################################################################
from psdi.mbo import MboConstants
from psdi.mbo import MboSetRemote
from psdi.mbo import Mbo
from psdi.server import MXServer
from psdi.webclient.system.beans import ResultsBean
from psdi.util.logging import MXLoggerFactory
from psdi.common.context import UIContext
from psdi.webclient.system.session import WebClientSessionManager
from psdi.webclient.system.controller import SessionContext, Utility, WebClientEvent
from java.lang.System import out
app=service.webclientsession().getCurrentApp().getAppBean().getSelection()
appName = service.webclientsession().getCurrentAppId()
appName = str(appName)
if interactive:
if app.size()==0:
service.error("LABTRANS", "NORECORDS")
else:
for i in range(0,app.size()):
flag1=0
flag2=0
record= app.get(i)
if(record.getString("SITEID")=="ELEC"):
if(record.getString("TRANSTYPE") in ['OUTAGE','DRIVEIA','RETURNIA']):
if(record.getString("FINCNTRLID")=="5540959"):
flag1=1
if(record.getString("VEHUNITID1")is None or record.getString("VEHUNITID1").strip()=="") and (record.getString("VEHUNITID2") is None or record.getString("VEHUNITID2")=='') and (record.getString("VEHUNITID3") is None or record.getString("VEHUNITID3")=="") and (record.getString("VEHUNITID4") is None or record.getString("VEHUNITID4")=="") and (record.getString("VEHUNITID5") is None or record.getString("VEHUNITID5")==""):
flag2=1
if(flag1==0 and flag2==0):
record.approveLaborTransaction()
record.setValue("FLAPPROVEDATE", MXServer.getMXServer().getDate(), MboConstants.NOACCESSCHECK)
if(flag1==1):
service.error("LABTRANS","FINCNTRLID")
elif(flag2==1):
service.error("LABTRANS","VEHICLES")
else:
record.approveLaborTransaction()
record.setValue("FLAPPROVEDATE", MXServer.getMXServer().getDate(), MboConstants.NOACCESSCHECK)
else:
record.approveLaborTransaction()
record.setValue("FLAPPROVEDATE", MXServer.getMXServer().getDate(), MboConstants.NOACCESSCHECK)
service.webclientsession().getCurrentApp().getAppBean().save()
service.webclientsession().getCurrentApp().getAppBean().reset()
=================================================================
this is working if there is file in the list page, but it doesn't throws any error if there is no record in the list. i am thinking i missed some code part to check the bean is empty or not.

i want to through out of box error "There is no records to approve" if there is no record in the list. please chck my code and correct where i need modifications
------------------------------
Regards
---------------------------
Karthik Krishnamurthy
---------------------------
------------------------------