this.ElementName = "Calendar2";
this.CCAPIName = "Calendar2";
this.ElementIDfield = "uniqueID";
var calendarStruct = StructNew();
var calendarArray = Application.ptCalendar2.ceData.getCEData(this.ElementName,this.ElementIDfield,TRIM(arguments.uniqueID));
if ( ArrayLen(calendarArray) )
calendarStruct = calendarArray[1];
var calendarStruct = StructNew();
var retStatusStruct = StructNew();
var dataValues = StructNew();
var newData = "";
var newCopySuffix = " - COPY";
retStatusStruct["msg"] = "failed";
calendarStruct = getCalendarEventByUniqueID(TRIM(arguments.uniqueID));
// Copy all the values of the existing source record to the destination struct
dataValues = calendarStruct.values;
// Update the ParentID of the Destination record with UniqueID from the source Record
dataValues.parentID = dataValues.uniqueID;
// Create a New UniqueID for the new Destination Record
dataValues.uniqueID = CreateUUID();
// if a nen event Title is passed in... use the new value
if ( LEN(TRIM(arguments.newTitle)) )
dataValues.title = TRIM(arguments.newTitle);
else
dataValues.title = dataValues.title & newCopySuffix;
// update the event date the selected interval
switch(TRIM(arguments.interval)) {
case "day":
{
dataValues.eventdate = DateAdd("d",1,dataValues.eventdate);
break;
}
case "week":
{
dataValues.eventdate = DateAdd("ww",1,dataValues.eventdate);
break;
}
case "month":
{
dataValues.eventdate = DateAdd("m",1,dataValues.eventdate);
break;
}
case "year":
{
dataValues.eventdate = DateAdd("yyyy",1,dataValues.eventdate);
break;
}
default:
{
// Do nothing if none match
break;
}
}
// If an interval is added to the EventDate fix the eventdate, starttime and endtime values
if ( LEN(TRIM(arguments.interval)) ) {
dataValues.eventdate = Application.ptCalendar2.Date.csDateFormat(DateFormat(dataValues.eventdate),TimeFormat(dataValues.eventdate));
dataValues.starttime = Application.ptCalendar2.Date.csDateFormat(DateFormat(dataValues.eventdate),TimeFormat(dataValues.starttime));
dataValues.endtime = Application.ptCalendar2.Date.csDateFormat(DateFormat(dataValues.eventdate),TimeFormat(dataValues.endtime));
}
retStatusStruct = calendarCCAPI(dataValues);
if ( retStatusStruct["CONTENTUPDATED"] IS true )
retStatusStruct["newUniqueID"] = dataValues.uniqueID;
else
retStatusStruct["newUniqueID"] = "";
var retStatusStruct = "failed";
// Create the CS Content CFC
var csContent = server.ADF.objectFactory.getBean("CSContent_1_0");
//application.ADF.utils.doDump(arguments.dataValues,"arguments.dataValues", false);
// Create the page
retStatusStruct = csContent.populateContent(this.CCAPIName, arguments.dataValues);
/* retStatusStruct RETURNS: CONTENTUPDATED : true/false & CONTENTUPDATERESPONSE: Success:1 */