Hi there,
I have a requirement to compare a date in Service Request application with two other dates in child table naming, start date and end date.
Here, Child table(in this case, BOOKING) has multiple rows, each row consisting Start date and End date. Now, a validation has to be done on date field in Service Request application by comparing it with each row of Start Date and End Date.
To achieve this,
1) Created a relationship between SR and BOOKING.
2) Created attribute launch point on the date field of Service Request and written the following script:
from psdi.server import MXServer
from psdi.mbo import Mbo
from java.util import Calendar
from java.util import Date
description=mbo.getString("DESCRIPTION")
if (description=="Use of IT E-Center"):
offstartdate=mbo.getDate("OFFSTARTDATE")
cal=Calendar.getInstance()
datetime=cal.getTime()
if(offstartdate <= datetime):
errorkey = 'Start Date should be greater than current date'
errorgroup = 'system'
else:
offbooking=mbo.getMboSet("BOOK")
i=0
records=offbooking.getMbo(i)
while(records is not None):
i=i+1
startdate=records.getDate("STARTDATE")
enddate=records.getDate("ENDDATE")
if (startdate <= offstartdate <= enddate):
errorkey = 'Start Date is between booked date'
errorgroup = 'system'
break
records=offbooking.getMbo(i)
Here,
OFFSTARTDATE: is the date field which has to be validated
STARTDATE and ENDDATE: are the fields with which OFFSTARTDATE has to be compared with
BOOK: is name of the relationship between SR and BOOKING tables
We had no luck because the script did not work, So any help here is appreciated.
#Customizations------------------------------
Harshavardhan Kamepalli
Eidiko System Integrators
------------------------------