This document assumes you are involved in the Deactivation process of Legacy FSU and have access to the PSOFT database located on FSUSQL2019.
IMPORTANT:
- Ensure backups are created before working with these tables, or ensure a full database backup is available.
- These scripts operate against the following tables:
- SY_FSU_Web_Customer
- SY_FSU_Web_Company
- SY_FSU_Web_Company_User
- SY_FSU_Web_User
CUSTOMER IDENTIFICATION:
- The @CustomerNumber value should be the SedonaOffice Account Number. [ This should match the Company / Username used in the Tech Manager Admin Tool.
TECH MANAGER ADMIN TOOL: http://fieldserviceunitweb.customer.sedonaoffice.com:8080/Anonymous/Login.aspx?ReturnUrl=%2fManagement%2fFSUWebCustomer.aspx
LEGACY FSU ACTIVATION TOOL: https://sedonafsucentral.sedonaoffice.com:4435/Anonymous/Login.aspx
SCRIPT 1 - DISPLAY ALL TECHNICIANS
Purpose: Displays all technicians associated with the defined SedonaOffice customer.
- Results should match the technicians shown for that customer in the Legacy FSU Activation Tool.
Before running: Change @CustomerNumber to the SedonaOffice Account Number.
This script does NOT make any database changes.
DECLARE @CustomerNumber varchar(20) = '#####';SELECT DISTINCTCU.Username AS CustomerNumber,C.SedonaCompanyName,U.Employee_Id,U.Username,U.TechName,U.IsApprovedFROM dbo.SY_FSU_Web_Customer CUINNER JOIN dbo.SY_FSU_Web_Company CON C.FSU_Web_Customer_Id = CU.FSU_Web_Customer_IdINNER JOIN dbo.SY_FSU_Web_Company_User WCUON WCU.FSU_Web_Company_Id = C.FSU_Web_Company_IdINNER JOIN dbo.SY_FSU_Web_User UON U.FSU_Web_User_Id = WCU.FSU_Web_User_IdWHERE CU.Username = @CustomerNumberORDER BYC.SedonaCompanyName,U.TechName;
SCRIPT 2 - COUNT AND DISPLAY CURRENTLY APPROVED TECHNICIANS
Purpose: Returns the total number of currently approved technicians. [ Displays only technicians where IsApproved = 1.]
- Run this script BEFORE Script 3 to establish the number of technicians that should be deactivated.
- Run this script AGAIN after Script 3 to verify the ApprovedTechCount is 0.
-The results should match the approved technicians shown in the Legacy FSU Activation Tool.
-This script does NOT make any database changes.
DECLARE @CustomerNumber varchar(20) = '#####';-- Total currently approved technicians for this customerSELECTCOUNT(DISTINCT U.FSU_Web_User_Id) AS ApprovedTechCountFROM dbo.SY_FSU_Web_Customer CUINNER JOIN dbo.SY_FSU_Web_Company CON C.FSU_Web_Customer_Id = CU.FSU_Web_Customer_IdINNER JOIN dbo.SY_FSU_Web_Company_User WCUON WCU.FSU_Web_Company_Id = C.FSU_Web_Company_IdINNER JOIN dbo.SY_FSU_Web_User UON U.FSU_Web_User_Id = WCU.FSU_Web_User_IdWHERE CU.Username = @CustomerNumberAND U.IsApproved = 1;-- List of currently approved techniciansSELECT DISTINCTCU.Username AS CustomerNumber,C.SedonaCompanyName,U.Employee_Id,U.Username,U.TechName,U.IsApprovedFROM dbo.SY_FSU_Web_Customer CUINNER JOIN dbo.SY_FSU_Web_Company CON C.FSU_Web_Customer_Id = CU.FSU_Web_Customer_IdINNER JOIN dbo.SY_FSU_Web_Company_User WCUON WCU.FSU_Web_Company_Id = C.FSU_Web_Company_IdINNER JOIN dbo.SY_FSU_Web_User UON U.FSU_Web_User_Id = WCU.FSU_Web_User_IdWHERE CU.Username = @CustomerNumberAND U.IsApproved = 1ORDER BYC.SedonaCompanyName,U.TechName;
SCRIPT 3 - DEACTIVATE APPROVED TECHNICIANS
Purpose: Deactivates all currently approved technicians associated with the defined SedonaOffice customer. [ Changes IsApproved from 1 to 0]
& Sets TerminationDate to today's date.
-Before running:
- Confirm @CustomerNumber is correct.
- Run Script 2 first and record ApprovedTechCount.
- Review the OUTPUT from this script before committing the change.
IMPORTANT:
- This version uses ROLLBACK for TESTING.
- After verifying the OUTPUT is correct, change: ROLLBACK TRANSACTION; to: COMMIT TRANSACTION;
After committing:
- Run Script 2 again. The ApprovedTechCount should be 0. [tech list should return no rows / You can also verify the results in the Legacy FSU Activation Tool]
Legacy FSU Activation Tool: https://sedonafsucentral.sedonaoffice.com:4435/Anonymous/Login.aspx
DECLARE @CustomerNumber varchar(20) = '#####';BEGIN TRANSACTION;UPDATE USETU.IsApproved = 0,U.TerminationDate = CAST(GETDATE() AS date)OUTPUTdeleted.Employee_Id,deleted.Username,deleted.TechName,deleted.IsApproved AS OldIsApproved,inserted.IsApproved AS NewIsApproved,deleted.TerminationDate AS OldTerminationDate,inserted.TerminationDate AS NewTerminationDateFROM dbo.SY_FSU_Web_User UINNER JOIN dbo.SY_FSU_Web_Company_User WCUON WCU.FSU_Web_User_Id = U.FSU_Web_User_IdINNER JOIN dbo.SY_FSU_Web_Company CON C.FSU_Web_Company_Id = WCU.FSU_Web_Company_IdINNER JOIN dbo.SY_FSU_Web_Customer CUON CU.FSU_Web_Customer_Id = C.FSU_Web_Customer_IdWHERE CU.Username = @CustomerNumberAND U.IsApproved = 1;-- TEST ONLY --ROLLBACK TRANSACTION;-- AFTER REVIEWING THE OUTPUT:Replace the ROLLBACK above with:-- COMMIT TRANSACTION;