var newDataStruct = arguments.eventData;
var elementName = application.ptCalendar.getEventDateTimeCEName();
var fieldStruct = application.ptCalendar.ceData.defaultFieldStruct(elementName);
var retStatusStruct = StructNew();
var dataValues = StructNew();
var exceptionFieldList = "uniqueID,calEventID,parentRecurrenceID";
var key = "";
var newEventSuffix = getBrokenRecurrenceEventSuffix();
retStatusStruct["msg"] = "failed";
retStatusStruct["CONTENTUPDATED"] = false;
retStatusStruct["newDateTimeID"] = "";
retStatusStruct["parentEventID"] = "";
retStatusStruct["parentRecurrenceID"] = "";
// Use the data from the newDataStruct to populate the fields from the fieldStruct
for (key in fieldStruct) {
// Do Not Copy any of the Data from the fields in the exceptionFieldList
if ( StructKeyExists(newDataStruct,key) AND ListFindNoCase(exceptionFieldList,key) EQ 0 ) {
dataValues[key] = newDataStruct[key];
}
}
// Create a New UniqueID for the new Destination Record
dataValues.uniqueID = CreateUUID();
dataValues.calEventID = "";
// Update the calEventID of the Destination record with the calEventID that was passed in
if ( LEN(TRIM(arguments.calEventID)) )
dataValues.calEventID = arguments.calEventID;
dataValues.parentRecurrenceID = "";
// Update the parentRecurrenceID of the Destination record with the parentRecurrenceID that was passed in
if ( LEN(TRIM(arguments.parentRecurrenceID)) )
dataValues.parentRecurrenceID = arguments.parentRecurrenceID;
// If provided add the suffix to the title
if ( LEN(TRIM(newEventSuffix)) )
dataValues.title = newDataStruct.title & " " & newEventSuffix;
// Process the CCAPI call to create the NEW record
retStatusStruct = application.ptCalendar.dateTimeBuilderDAO.eventDateTimeCCAPI(dataValues);
// If the CCAPI create the newEvent record set the newEventID in the return struct
if ( retStatusStruct["CONTENTUPDATED"] IS true ) {
retStatusStruct["newDateTimeID"] = dataValues.uniqueID;
retStatusStruct["parentRecurrenceID"] = dataValues.parentRecurrenceID;
}
if ( StructKeyExists(newDataStruct,"calEventID") )
retStatusStruct["parentEventID"] = newDataStruct.calEventID;
return retStatusStruct;
var dataArray = ArrayNew(1);
var retStatusStruct = StructNew();
var copyStatusStruct = StructNew();
var dataValues = StructNew();
var newData = "";
var itm = 1;
if ( LEN(TRIM(arguments.srcUUIDlist)) )
dataArray = application.ptCalendar.dateTimeBuilderDAO.getDateTimeData(uuid=TRIM(arguments.srcUUIDlist));
//application.ptCalendar.utils.doDump(dataArray,"dataArray",0);
for ( itm = 1; itm LTE ArrayLen(dataArray); itm=itm+1 ) {
// Reset the dataValues struct
dataValues = StructNew();
if ( StructKeyExists(dataArray[itm],"values") ) {
// Copy all the values of the existing source record to the destination struct
dataValues = dataArray[itm].values;
// Update the calEventID of the Destination record with arguments.calEventID from the newly create event
dataValues.calEventID = arguments.calEventID;
// Create a New UniqueID for the new Destination Record
dataValues.uniqueID = CreateUUID();
// Process the CCAPI call to create the new records
copyStatusStruct = application.ptCalendar.dateTimeBuilderDAO.eventDateTimeCCAPI(dataValues);
// If the CCAPI create the newEvent record set the newEventID in the return struct
if ( copyStatusStruct["CONTENTUPDATED"] IS true ) {
// Add the copy status for this iteration to the return struct
retStatusStruct[dataValues.uniqueID] = copyStatusStruct;
retStatusStruct[dataValues.uniqueID]["calEventID"] = arguments.calEventID;
retStatusStruct[dataValues.uniqueID]["newDateTimeID"] = dataValues.uniqueID;
}
else {
retStatusStruct[dataValues.uniqueID]["msg"] = "failed";
retStatusStruct[dataValues.uniqueID]["CONTENTUPDATED"] = false;
retStatusStruct[dataValues.uniqueID]["calEventID"] = arguments.calEventID;
retStatusStruct[dataValues.uniqueID]["newDateTimeID"] = "";
// TODO: Log CCAPI content create failure
}
}
else {
// TODO: Log date get issue
}
}
return retStatusStruct;