Legacy FSU Mass Tech Deactivation Scripts for Professional/Hosted Services

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 DISTINCT
    CU.Username AS CustomerNumber,
    C.SedonaCompanyName,
    U.Employee_Id,
    U.Username,
    U.TechName,
    U.IsApproved
FROM dbo.SY_FSU_Web_Customer CU

INNER JOIN dbo.SY_FSU_Web_Company C
    ON C.FSU_Web_Customer_Id = CU.FSU_Web_Customer_Id

INNER JOIN dbo.SY_FSU_Web_Company_User WCU
    ON WCU.FSU_Web_Company_Id = C.FSU_Web_Company_Id

INNER JOIN dbo.SY_FSU_Web_User U
    ON U.FSU_Web_User_Id = WCU.FSU_Web_User_Id

WHERE CU.Username = @CustomerNumber

ORDER BY
    C.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 customer
SELECT
    COUNT(DISTINCT U.FSU_Web_User_Id) AS ApprovedTechCount
FROM dbo.SY_FSU_Web_Customer CU

INNER JOIN dbo.SY_FSU_Web_Company C
    ON C.FSU_Web_Customer_Id = CU.FSU_Web_Customer_Id

INNER JOIN dbo.SY_FSU_Web_Company_User WCU
    ON WCU.FSU_Web_Company_Id = C.FSU_Web_Company_Id

INNER JOIN dbo.SY_FSU_Web_User U
    ON U.FSU_Web_User_Id = WCU.FSU_Web_User_Id

WHERE CU.Username = @CustomerNumber
  AND U.IsApproved = 1;

-- List of currently approved technicians
SELECT DISTINCT
    CU.Username AS CustomerNumber,
    C.SedonaCompanyName,
    U.Employee_Id,
    U.Username,
    U.TechName,
    U.IsApproved
FROM dbo.SY_FSU_Web_Customer CU

INNER JOIN dbo.SY_FSU_Web_Company C
    ON C.FSU_Web_Customer_Id = CU.FSU_Web_Customer_Id

INNER JOIN dbo.SY_FSU_Web_Company_User WCU
    ON WCU.FSU_Web_Company_Id = C.FSU_Web_Company_Id

INNER JOIN dbo.SY_FSU_Web_User U
    ON U.FSU_Web_User_Id = WCU.FSU_Web_User_Id

WHERE CU.Username = @CustomerNumber
  AND U.IsApproved = 1

ORDER BY
    C.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 U
SET
    U.IsApproved = 0,
    U.TerminationDate = CAST(GETDATE() AS date)
OUTPUT
    deleted.Employee_Id,
    deleted.Username,
    deleted.TechName,
    deleted.IsApproved AS OldIsApproved,
    inserted.IsApproved AS NewIsApproved,
    deleted.TerminationDate AS OldTerminationDate,
    inserted.TerminationDate AS NewTerminationDate

FROM dbo.SY_FSU_Web_User U

INNER JOIN dbo.SY_FSU_Web_Company_User WCU
    ON WCU.FSU_Web_User_Id = U.FSU_Web_User_Id

INNER JOIN dbo.SY_FSU_Web_Company C
    ON C.FSU_Web_Company_Id = WCU.FSU_Web_Company_Id

INNER JOIN dbo.SY_FSU_Web_Customer CU
    ON CU.FSU_Web_Customer_Id = C.FSU_Web_Customer_Id

WHERE CU.Username = @CustomerNumber
  AND U.IsApproved = 1;


-- TEST ONLY --
ROLLBACK TRANSACTION;

-- AFTER REVIEWING THE OUTPUT: Replace the ROLLBACK above with:
-- COMMIT TRANSACTION;
Was this article helpful?
Thank you for your feedback!
User Icon

Thank you! Your comment has been submitted for approval.