// Verify the Form ID and Page ID if they exist
if ( StructKeyExists(attributes, "PageID")
AND StructKeyExists(attributes, "ControlID")
AND StructKeyExists(attributes, "ItemID")
AND LEN(attributes.ItemID) ) {
// Validate the sync app and mapping cache variables are configured
if ( StructKeyExists(application, "ptSync")
AND StructKeyExists(application.ptSync, "cache")
AND StructKeyExists(application.ptSync.cache, "mapSrcFormIDList")
AND ListLen(application.ptSync.cache.mapSrcFormIDList) ){
// Get the form ID based on the PageID and ControlID
formid = application.ptSync.ceData.getFormIDFromPageID(pageid=attributes.PageID,controlid=attributes.ControlID);
// Validate the Form ID exists for the Sync Mapping
if ( ListFind(application.ptSync.cache.mapSrcFormIDList, formid) ) {
// Get the UUID field ID
uuidFieldID = application.ptSync.cache.mappingData[formid].values.uuidField;
// Check if the ITEMID field contains the uuidFieldID
// This will allow the update to only run for the UUID field (not multiple times)
if ( attributes.ItemID CONTAINS uuidFieldID ) {
// Check if the current record is active or deleted
recSubmitToDelete = application.ptSync.syncDAO.isRecordPendingDelete(formID=formid,pageid=attributes.PageID,controlid=attributes.ControlID);
if ( recSubmitToDelete ) {
// Delete the sync'd record from the destination site
syncStatus = application.ptSync.syncController.scheduleDeleteSyncLocalCE(srcFormID=formid, srcDataPageID=attributes.PageID, srcControlID=attributes.ControlID);
}
else {
// Schedule the sync for the record
syncStatus = application.ptSync.syncController.scheduleSync(srcFormID=formid, srcDataPageID=attributes.PageID, srcControlID=attributes.ControlID);
}
}
else {
// Set the sync status variable
syncStatus = "none";
}
/* // UNCOMMENT to Write Debug Log File
logArray = ArrayNew(1);
logStruct = StructNew();
logStruct.msg = "#request.formattedTimeStamp# - syncStatus = #syncStatus# - recSubmitToDelete = #recSubmitToDelete#";
logStruct.logFile = 'PT_Sync_Post_Approve_Status.log';
arrayAppend(logArray, logStruct);
application.ptSync.utils.bulkLogAppend(logArray);
*/
/* // UNCOMMENT to STOP Processing to Debug
application.ptSync.utils.dodump(syncStatus, "syncStatus", false);
application.ptSync.utils.abort();
*/
}
}
}