// Verify the Form ID and Page ID if they exist if ( StructKeyExists(attributes.INPUTSTRUCT, "formid") AND StructKeyExists(attributes.INPUTSTRUCT, "pageID") ) { // 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) ){ // Validate the Form ID exists for the Sync Mapping if ( ListFind(application.ptSync.cache.mapSrcFormIDList, attributes.inputStruct.formid) ) { // Check if this is for a save or edit. // If save, then schedule process to run sync job // If update, then run sync right away if ( StructKeyExists(attributes.INPUTSTRUCT, "formEvent") AND attributes.INPUTSTRUCT.formEvent EQ "save" ){ // Get the UUID field value for the record to pass into the schedule. // The "ATTRIBUTES.PAGEID" is not the data page id on a new record. // Build the "FIC_#formid#_#fieldid#" for the UUID field. uuidFieldID = application.ptSync.cache.mappingData[attributes.inputStruct.formid].values.uuidField; uuidFieldName = "FIC_" & attributes.inputStruct.formid & "_" & uuidFieldID; if ( StructKeyExists(attributes.INPUTSTRUCT, uuidFieldName) ) uuidFieldVal = attributes.INPUTSTRUCT[uuidFieldName]; else uuidFieldVal = "null"; // Handle SYNC for the NEW record syncStatus = application.ptSync.syncController.processNewGlobalCESync(srcFormID=attributes.inputStruct.formid, srcUUID=uuidFieldVal, srcUUIDFieldID=uuidFieldID); } else if ( StructKeyExists(attributes.INPUTSTRUCT, "formEvent") AND attributes.INPUTSTRUCT.formEvent EQ "update" ){ // Check the run time sync is enabled if ( application.ptSync.appConfig.runTimeSync ){ // Run the SYNC for the record syncStatus = application.ptSync.syncController.processSync(srcFormID=attributes.inputStruct.formid, srcDataPageID=attributes.inputStruct.pageID); } else { // Schedule the SYNC for the record syncStatus = application.ptSync.syncController.scheduleSync(srcFormID=attributes.inputStruct.formid, srcDataPageID=attributes.inputStruct.pageID); } } else { syncStatus = "none"; } /* // UNCOMMENT to Write Debug Log File logArray = ArrayNew(1); logStruct = StructNew(); logStruct.msg = "#request.formattedTimeStamp# - syncStatus = #syncStatus#"; 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(); */ } } }