local loErr, lcBatch_Process_fk, lcUsGrLink_fk, ; lcNewStatusCode, lcDept, lnNumber_of_Days, ; ltTimeToReschedule, lcTrans_pk, lcTrans_Employees_Queues_pk, lcUser, ; lcAction, lcSubAction, lcDetail, lcOldCode, lcUsGrLink, llOldRecords =aused(this.arrOriginallyUsed) with this try .CreateLogfile() .WriteToLogFile(chr(13) + chr(10) + replicate("*",75) + chr(13) + chr(10), .t.) .WriteToLogFile("Started to run " + this.cSearchType + " Name Search process") .OpenSearchTables() && Opens related tables with buffering lcBatch_Processes_Fk = Get_Batch_Processes_Fk_By_Process_Name('POLICY NUMBER CHECK ') lcNewStatusCode = "NSR" && Name Search Requested if vartype(m.goApp) = "O" lcDept = m.goApp.cDept .nNumber_of_Days = m.goApp.oSystemParametersRecord.iNum_Days_NS_check .nNum_days_ns_Dos = m.goApp.oSystemParametersRecord.iNum_days_ns_dos lcUser = m.goApp.cUserID lcUsGrLink = m.goApp.cUsGrLink else lcDept = "O" .nNumber_of_Days = 5 .nNum_days_ns_Dos = 716 lcUser = GetUserID() lcUsGrLink = Get_System_USGRLink() endif =Get_description_from_Viscodes("STATUS","", m.lcDept, ; "cTempInfo",.f., 1, 'cCode_Value = "' + m.lcNewStatusCode + '"') lcNewStatusCode = cTempInfo.cVisCodes_pk use in select('cTempInfo') .SetDateToReschedule(.nNumber_of_Days) ltTimeToReschedule = dtot(.dRescheduleDate) + 9 * 3600 && 9am select curProcess scan if not empty(.cError) or .lStopProcess exit endif if .CheckRules() lcTrans_pk = curProcess.cTrans_pk lcTrans_Employees_Queues_pk = curProcess.cTrans_Employees_Queues_pk insert into Scheduled_Processes ; (cPROCESS_NAME_FK, cTrans_fk, cUsGrLink_fk, iBatch_Number, ; cClient_Code, cDepartment_Code, cProduct_Line_Code, ; tDate_Process_Scheduled, iStatus_Flag) ; values ; (m.lcBatch_Processes_Fk, m.lcTrans_pk, m.lcUsGrLink, 0, ; curProcess.cClient_Code, ; curProcess.cDepartment_Code, curProcess.cProduct_Line_Code, ; datetime(), 1) if seek(m.lcTrans_pk, "Trans") replace cStatus_Codes_fk with m.lcNewStatusCode, ; tStatus_Date with datetime(), ; cLast_Updated_User with m.lcUser, ; tLast_Updated_Date with datetime() ; in trans endif select Trans_Status_Codes if seek(m.lcTrans_pk) llOldRecords = .t. scan while cTrans_fk = m.lcTrans_pk replace cLast_Updated_User with m.lcUser, ; tLast_Updated_Date with datetime(), ; iActive_flag with 0 ; in Trans_Status_Codes endscan else llOldRecords = .f. endif if not m.llOldRecords && There were no status records already lcAction = "AD" lcSubAction = "" lcDetail = "STATUS WAS ADDED ON " + ; transform(datetime()) + " BY " + m.lcUser else lcAction = "CH" && change lcSubAction = "FR" if seek(curProcess.cStatus_Codes_fk, "VisCodes") lcOldCode = VisCodes.cCode_Description else lcOldCode = "OLD CODE" endif lcDetail = "STATUS WAS CHANGED FROM " + m.lcOldCode + ; " ON " + transform(datetime()) + " BY " + m.lcUser endif insert into Trans_Status_Codes ; (cTrans_fk, cStatus_Codes_fk, cUsGrLink_fk, tAS_OF_DATE, iActive_flag) ; values ; (m.lcTrans_pk, curProcess.cStatus_Codes_fk, m.lcUsGrLink, datetime(), 1) insert into Trans_Events ; (cTrans_fk, cFUNCTION_CODE, cACTION_CODE, cSUBACTION_CODE, cDETAIL_INFO) ; values ; (m.lcTrans_pk, "ST", m.lcAction, m.lcSubAction, m.lcDetail) select Employee_Queue_Schedules if seek(m.lcTrans_Employees_Queues_pk) scan while cTrans_Employees_Queues_fk = m.lcTrans_Employees_Queues_pk replace iActive_flag with 0, ; cLast_Updated_User with m.lcUser, ; tLast_Updated_Date with datetime() ; in Employee_Queue_Schedules endscan endif insert into Employee_Queue_Schedules (cTrans_Employees_Queues_fk, ; cDIARY_CODE_FK, ; tScheduled_Time, iActive_flag, ; iACTIVE_AT_DAY_START_FLAG, iSUPERVISOR_ASSIGNED_FLAG) ; values ; (m.lcTrans_Employees_Queues_pk, null, m.ltTimeToReschedule, 1, 1, 0) endif endscan if empty(.cError) and not .lStopProcess .CommitChanges() endif .WriteToLogFile("Finished to run " + this.cSearchType + " Name Search process" + chr(13) + chr(10)) catch to loErr .CustomError(m.loErr) finally release loErr .CleanUp() endtry endwith return>Hi Naomi,