var retList = arguments.currList;
var idPos = 0;
if ( arguments.actionType EQ "add" )
{
// Check to make sure the value is NOT in the list
if ( ListFindNoCase(retList, arguments.currItem) EQ 0 )
{
// Handle the ADD action
retList = ListAppend(retList, arguments.currItem);
}
}
else if ( arguments.actionType EQ "remove" )
{
// Check if the value is in the list
if ( ListFindNoCase(retList, arguments.currItem) )
{
// Handle the REMOVE action
idPos = ListFindNoCase(retList, arguments.currItem);
retList = ListDeleteAt(retList, idPos);
}
}
return retList;
var retStruct = StructNew();
var tmpData = StructNew();
var elementName = application.ptCalendar.getEventRecurrenceCEName();
var elementFields = application.ptCalendar.ceData.defaultFieldStruct(elementName);
var key = "";
var dummyDTstamp = "";
var dummyDate = getTimeDummyDate(); // Get from the App so all time fields use the same dummy date in date/time stamp
var dummyDayBeginTime = getDayBeginTime(); // Get from the App so all date fields use the same dummy time in date/time stamp
var dummyDayEndTime = getDayEndTime(); // Get from the App so all date fields use the same dummy time in date/time stamp
// Use the buildCleanRecurrenceData data function to clean up/remove the misc submitted entries
tmpData = buildCleanRecurrenceData(arguments.formParams);
// Loop over the available element fields
for ( key in elementFields ) {
dtStamp = "";
// if a key matches a field in the formParams add it to the retStruct
if ( StructKeyExists(tmpData,key) )
{
// Set the execptions to the rule. ie. Format Times and Dates with CS datetime stamp
if ( key EQ "recurStartTime" AND StructKeyExists(tmpData,key) AND LEN(TRIM(tmpData[key])) )
{
// Create a dummy date/time stamp using the dummyDate value and the recurStartTime
dummyDTstamp = dummyDate & " " & tmpData[key];
if ( application.ptCalendar.date.IsRealDate(dummyDTstamp) )
{
// Format with CS date/time stamp
retStruct[key] = application.ptCalendar.date.csDateFormat(dummyDTstamp,dummyDTstamp);
}
}
else if ( key EQ "recurEndTime" AND StructKeyExists(tmpData,key) AND LEN(TRIM(tmpData[key])) )
{
// Create a dummy date/time stamp using the dummyDate value and the recurEndTime
dummyDTstamp = dummyDate & " " & tmpData[key];
if ( application.ptCalendar.date.IsRealDate(dummyDTstamp) )
{
// Format with CS date/time stamp
retStruct[key] = application.ptCalendar.date.csDateFormat(dummyDTstamp,dummyDTstamp);
}
}
else if ( key EQ "rangeStartDate" AND StructKeyExists(tmpData,key) AND LEN(TRIM(tmpData[key])) )
{
// Create a dummy date/time stamp using the rangeStartDate value and the dummyDayBeginTime
dummyDTstamp = tmpData[key] & " " & dummyDayBeginTime;
if ( application.ptCalendar.date.IsRealDate(dummyDTstamp) )
{
// Format with CS date/time stamp
retStruct[key] = application.ptCalendar.date.csDateFormat(dummyDTstamp,dummyDTstamp);
}
}
else if ( key EQ "rangeEndDate" AND StructKeyExists(tmpData,key) AND LEN(TRIM(tmpData[key])) )
{
// Create a dummy date/time stamp using the rangeEndDate value and the dummyDayEndTime
dummyDTstamp = tmpData[key] & " " & dummyDayEndTime;
if ( application.ptCalendar.date.IsRealDate(dummyDTstamp) )
{
// Format with CS date/time stamp
retStruct[key] = application.ptCalendar.date.csDateFormat(dummyDTstamp,dummyDTstamp);
}
}
else
{
// Add "unprocessed" data to all other matching fields
if ( StructKeyExists(tmpData,key) )
retStruct[key] = tmpData[key];
}
}
// Set the values for recurrence uniqueID from the recurrenceID
if ( StructKeyExists(elementFields,"uniqueID") AND StructKeyExists(formParams,"recurrenceID") )
retStruct.uniqueID = formParams.recurrenceID;
// Set the values for recurrence calEventID from the eventID
if ( StructKeyExists(elementFields,"calEventID") AND StructKeyExists(formParams,"eventID") )
retStruct.calEventID = formParams.eventID;
}
return retStruct;
var retStruct = StructNew();
var currData = arguments.recurrenceData;
var d = 1;
var wkDay = "";
var wkDayString = "";
var patternOptionList = "EveryXDays,EveryWeekday,WeeklyDays,MonthlyDayX,MonthlyXY,YearlyXY,YearlyXYofZ";
var cfDateDisplayMask = application.ptCalendar.getDisplayCFdateMask();
var cfTimeDisplayMask = application.ptCalendar.getDisplayCFtimeMask();
var cfDateSortMask = application.ptCalendar.getSortingCFdateMask(); // "YYYY/MM/DD" - DATE FORMAT FOR SORTING
var cfTimeSortMask = application.ptCalendar.getSortingCFtimeMask(); // "HH:mm" - TIME FORMAT FOR SORTING
var mthlyDayOrdinalSuffix = "";
var yrlyDayOrdinalSuffix = "";
// Recurrence meta defaults
retStruct.uniqueID = "";
retStruct.calEventID = "";
// Recurrence Time defaults
retStruct.recurStartTime = "";
retStruct.recurStartTimeFull = ""; //extra
retStruct.recurStartTimeSort = ""; //extra
retStruct.recurEndTime = "";
retStruct.recurEndTimeFull = ""; //extra
retStruct.recurEndTimeSort = ""; //extra
retStruct.recurAllDay = "";
retStruct.recurAllDayString = ""; //extra
// Recurrence Pattern defaults
retStruct.patternType = "Weekly";
retStruct.patternOption = "";
// Recurrence Pattern defaults - daily
retStruct.patternDayQty = "";
// Recurrence Pattern defaults - weekly
retStruct.patternWeekQty = "";
retStruct.patternDOW = "";
retStruct.patternDOWstring = ""; //extra
retStruct.patternDOWabbrString = ""; //extra
// Recurrence Pattern defaults - monthly
retStruct.patternMonthQty = "";
retStruct.patternMonthlyDayNumber = "";
retStruct.patternMonthlyDayNumberString = ""; //extra
retStruct.patternMonthlyDayOrdinal = "";
retStruct.patternMonthlyWeekDay = "";
// Recurrence Pattern defaults - yearly
retStruct.patternYearQty = "";
retStruct.patternYearlyMonth = "";
retStruct.patternYearlyMonthString = ""; //extra
retStruct.patternYearlyDayNumber = "";
retStruct.patternYearlyDayNumberString = ""; //extra
retStruct.patternYearlyDayOrdinal = "";
retStruct.patternYearlyWeekDay = "";
retStruct.patternYearlyWeekDayMonth = "";
retStruct.patternYearlyWeekDayMonthString = ""; //extra
// Recurrence Range Defaults
retStruct.rangeStartDate = "";
retStruct.rangeEndType = "";
retStruct.rangeEndDate = "";
retStruct.rangeQuantity = "";
// Start Building the retStruct from currData values
if ( StructKeyExists(currData,"uniqueID") )
retStruct.uniqueID = currData.uniqueID;
if ( StructKeyExists(currData,"calEventID") )
retStruct.calEventID = currData.calEventID;
// Recurrence Time data
if ( StructKeyExists(currData,"recurAllDay") AND currData.recurAllDay EQ 1 )
{
retStruct.recurAllDay = 1;
retStruct.recurAllDayString = "All Day";
}
else
{
retStruct.recurAllDay = 0;
if ( StructKeyExists(currData,"recurStartTime") AND application.ptCalendar.date.IsRealDate(currData.recurStartTime) )
{
retStruct.recurStartTime = TimeFormat(currData.recurStartTime,cfTimeDisplayMask);
retStruct.recurStartTimeFull = TimeFormat(currData.recurStartTime,'full');
retStruct.recurStartTimeSort = TimeFormat(currData.recurStartTime,cfTimeSortMask);
}
if ( StructKeyExists(currData,"recurEndTime") AND application.ptCalendar.date.IsRealDate(currData.recurEndTime) )
{
retStruct.recurEndTime = TimeFormat(currData.recurEndTime,cfTimeDisplayMask);
retStruct.recurEndTimeFull = TimeFormat(currData.recurEndTime,'full');
retStruct.recurEndTimeSort = TimeFormat(currData.recurEndTime,cfTimeSortMask);
}
}
// Recurrence Pattern data
if ( StructKeyExists(currData,"patternType") AND LEN(TRIM(currData.patternType)) )
retStruct.patternType = currData.patternType;
if ( StructKeyExists(currData,"patternOption") AND LEN(TRIM(currData.patternOption)) )
retStruct.patternOption = currData.patternOption;
if ( retStruct.patternType IS "Daily")
{
if ( ListFindNoCase("EveryXDays,EveryWeekday",retStruct.patternOption) EQ 0 )
retStruct.patternOption = "EveryXDays";
// Daily Pattern Data
if ( retStruct.patternOption EQ "EveryXDays" ) {
if ( StructKeyExists(currData,"patternDayQty") AND IsNumeric(currData.patternDayQty) )
retStruct.patternDayQty = currData.patternDayQty;
}
}
else if ( retStruct.patternType IS "Weekly")
{
// Weekly Pattern Data
retStruct.patternOption = "WeeklyDays";
if ( StructKeyExists(currData,"patternWeekQty") AND IsNumeric(currData.patternWeekQty) )
retStruct.patternWeekQty = currData.patternWeekQty;
if ( StructKeyExists(currData,"patternDOW") AND LEN(TRIM(currData.patternDOW)) ) {
retStruct.patternDOW = currData.patternDOW;
for (d=1; d LTE ListLen(retStruct.patternDOW);d=d+1) {
wkDay = ListGetAt(retStruct.patternDOW,d);
wkDayString = "";
wkDayAbbr = "";
if ( IsNumeric(wkDay) ) {
wkDayString = DayOfWeekAsString(wkDay);
wkDayAbbr = Left(wkDayString,3);
if ( LEN(TRIM(wkDayString)) ) {
if ( ListLen(retStruct.patternDOW) GT 1 AND ListLen(retStruct.patternDOW) EQ d ) {
retStruct.patternDOWstring = retStruct.patternDOWstring & " and " & wkDayString;
retStruct.patternDOWabbrString = retStruct.patternDOWabbrString & " and " & wkDayAbbr;
}
else {
retStruct.patternDOWstring = ListAppend(retStruct.patternDOWstring,wkDayString,",");
retStruct.patternDOWabbrString = ListAppend(retStruct.patternDOWabbrString,wkDayAbbr,",");
}
}
}
}
retStruct.patternDOWstring = ListChangeDelims(retStruct.patternDOWstring,", ",",");
retStruct.patternDOWabbrString = ListChangeDelims(retStruct.patternDOWabbrString,", ",",");
}
}
else if ( retStruct.patternType IS "Monthly")
{
if ( ListFindNoCase("MonthlyDayX,MonthlyXY",retStruct.patternOption) EQ 0 )
retStruct.patternOption = "MonthlyDayX";
// Monthly Pattern Data
if ( StructKeyExists(currData,"patternMonthQty") AND IsNumeric(currData.patternMonthQty) )
retStruct.patternMonthQty = currData.patternMonthQty;
if ( retStruct.patternOption EQ "MonthlyDayX" )
{
// Monthly Pattern Data - MonthlyDayX
if ( StructKeyExists(currData,"patternMonthlyDayNumber") AND IsNumeric(currData.patternMonthlyDayNumber) ) {
retStruct.patternMonthlyDayNumber = currData.patternMonthlyDayNumber;
mthlyDayOrdinalSuffix = application.ptCalendar.data.getOrdinalSuffixforNumber(number=currData.patternMonthlyDayNumber);
retStruct.patternMonthlyDayNumberString = currData.patternMonthlyDayNumber & mthlyDayOrdinalSuffix;
}
}
else if ( retStruct.patternOption EQ "MonthlyXY" )
{
// Monthly Pattern Data - MonthlyXY
if ( StructKeyExists(currData,"patternMonthlyDayOrdinal") AND LEN(TRIM(currData.patternMonthlyDayOrdinal)) )
retStruct.patternMonthlyDayOrdinal = currData.patternMonthlyDayOrdinal;
if ( StructKeyExists(currData,"patternMonthlyWeekDay") AND LEN(TRIM(currData.patternMonthlyWeekDay)) )
retStruct.patternMonthlyWeekDay = currData.patternMonthlyWeekDay;
}
}
else if ( retStruct.patternType IS "Yearly")
{
if ( ListFindNoCase("YearlyXY,YearlyXYofZ",retStruct.patternOption) EQ 0 )
retStruct.patternOption = "YearlyXY";
// Yearly Pattern Data
if ( StructKeyExists(currData,"patternYearQty") AND IsNumeric(currData.patternYearQty) )
retStruct.patternYearQty = currData.patternYearQty;
if ( retStruct.patternOption EQ "YearlyXY" )
{
// Yearly Pattern Data - YearlyXY
if ( StructKeyExists(currData,"patternYearlyMonth") AND IsNumeric(currData.patternYearlyMonth) ) {
retStruct.patternYearlyMonth = currData.patternYearlyMonth;
retStruct.patternYearlyMonthString = MonthAsString(currData.patternYearlyMonth);
}
if ( StructKeyExists(currData,"patternYearlyDayNumber") AND IsNumeric(currData.patternYearlyDayNumber) ) {
retStruct.patternYearlyDayNumber = currData.patternYearlyDayNumber;
yrlyDayOrdinalSuffix = application.ptCalendar.data.getOrdinalSuffixforNumber(number=currData.patternYearlyDayNumber);
retStruct.patternYearlyDayNumberString = currData.patternYearlyDayNumber & yrlyDayOrdinalSuffix;
}
}
else if ( retStruct.patternOption EQ "YearlyXYofZ" )
{
// Yearly Pattern Data - YearlyXYofZ
if ( StructKeyExists(currData,"patternYearlyDayOrdinal") AND LEN(TRIM(currData.patternYearlyDayOrdinal)) )
retStruct.patternYearlyDayOrdinal = currData.patternYearlyDayOrdinal;
if ( StructKeyExists(currData,"patternYearlyWeekDay") AND LEN(TRIM(currData.patternYearlyWeekDay)) )
retStruct.patternYearlyWeekDay = currData.patternYearlyWeekDay;
if ( StructKeyExists(currData,"patternYearlyWeekDayMonth") AND IsNumeric(currData.patternYearlyWeekDayMonth) ) {
retStruct.patternYearlyWeekDayMonth = currData.patternYearlyWeekDayMonth;
retStruct.patternYearlyWeekDayMonthString = MonthAsString(currData.patternYearlyWeekDayMonth);
}
}
}
// Recurrence Range Existing data
if ( StructKeyExists(currData,"rangeStartDate") AND application.ptCalendar.date.IsRealDate(currData.rangeStartDate) )
retStruct.rangeStartDate = DateFormat(currData.rangeStartDate,cfDateDisplayMask);
if ( StructKeyExists(currData,"rangeEndType") AND LEN(TRIM(currData.rangeEndType)) )
retStruct.rangeEndType = currData.rangeEndType;
// Range End Types: NoEnd,EndQuantity,EndDate
if ( retStruct.rangeEndType EQ "EndQuantity")
{
retStruct.rangeEndDate = ""; // set to [empty string]
if ( StructKeyExists(currData,"rangeQuantity") AND IsNumeric(currData.rangeQuantity) )
retStruct.rangeQuantity = currData.rangeQuantity;
}
else if ( retStruct.rangeEndType EQ "EndDate")
{
retStruct.rangeQuantity = ""; // set to [empty string]
if ( StructKeyExists(currData,"rangeEndDate") AND application.ptCalendar.date.IsRealDate(currData.rangeEndDate) )
retStruct.rangeEndDate = DateFormat(currData.rangeEndDate,cfDateDisplayMask);
}
return retStruct;
var recurrenceArray = application.ptCalendar.recurrenceBuilderDAO.getRecurrenceDataByCalEventID(calEventID=arguments.parentID);
var itm=1;
var retData = "";
// Loop over the returned data
for (itm=1; itm LTE ArrayLen(recurrenceArray); itm=itm+1) {
// Add the uniqueIDs to the retData list List
if ( StructKeyExists(recurrenceArray[itm],"values") AND StructKeyExists(recurrenceArray[itm].values,"uniqueID") AND LEN(TRIM(recurrenceArray[itm].Values.uniqueID)) )
retData = ListAppend(retData,recurrenceArray[itm].Values.uniqueID);
}
return retData;
var rData = application.ptCalendar.recurrenceBuilderDAO.getRecurrenceDataByCalEventID(calEventID=arguments.parentID);
var deletedItemStatus = false;
var deletedItemsList = "";
var itm = 0;
for ( itm=1; itm LTE ArrayLen(rData); itm=itm+1 ) {
if ( IsNumeric(rData[itm].pageID) AND rData[itm].pageID GT 0 ) {
deletedItemStatus = application.ptCalendar.recurrenceBuilderDAO.deleteRecurrenceData(rData[itm].pageID);
if ( deletedItemStatus ) {
deletedItemsList = ListAppend(deletedItemsList,rData[itm].values.uniqueID);
}
}
}
return deletedItemsList;