Matters: Trimming Client Numbers from Matter Numbers

Matters: Trimming Client Numbers from Matter Numbers

The following script will peel off client numbers from matter numbers.

For example, if a matter has a ReferenceCode like:

  1. ABC-0001

After the script runs, it will have a reference code of:

  1. 0001

 

Scenario 1: There are Client Reference Codes

In some systems, there are no Client reference codes.  This means that the Matter portion of the Matter's reference code needs to come by splitting based on a delimiter.

  1. --In this system, the Matter's ReferenceCode is prepended with
  2. --the Client's ReferenceCode and we don't want that.
  3. --However, Client's themselves dont have reference codes!
  4. --We are going to strip out everything past the first - in the matter's reference code.

  5. DECLARE @SEPARATOR nvarchar(MAX) = '-'

  6. UPDATE
  7. __M_Matters
  8. SET
  9. Final_ReferenceCode = SUBSTRING(Final_ReferenceCode, 1 + LEN(@SEPARATOR) + CHARINDEX(@SEPARATOR, Final_ReferenceCode), 99999)
  10. WHERE 1=1
  11. AND CharIndex(@SEPARATOR, Final_ReferenceCode) > 0

  12. GO


Scenario 2: There are No Client ReferenceCodes

In some systems, there are Client reference codes.  This means that the Matter portion of the Matter's reference code needs to come by splitting out on a delimiter.

  1. --In this system, the Matter's ReferenceCode is prepended with
  2. --the Client's ReferenceCode and we don't want that.
  3. --We are going to link matters to clients and then trim out the client reference codes.

  4. DECLARE @SEPARATOR nvarchar(MAX) = '-'

  5. UPDATE
  6. __M_Matters
  7. SET
  8. Final_ReferenceCode = Right(V2.Final_ReferenceCode, len(V2.Final_ReferenceCode) - len(V1.Final_ReferenceCode) - len(@SEPARATOR) )
  9. FROM
  10. __M_Contacts V1,
  11. __M_Matters V2
  12. WHERE 1=1
  13. AND V2.Final_ClientContact_Id = V1.Id
  14. AND CharIndex(V1.Final_ReferenceCode + @SEPARATOR, V2.Final_ReferenceCode) = 1

  15. GO



    • Related Articles

    • Matters: Prepending Client Names to Matters

      The following script will prepend Client Names to Matter Names. For Example: Divorce 2016 would become John Smith --- Divorce 2016 Here is the relevant script: --Prepend all matter descriptions with the client name. UPDATE __M_Matters SET ...
    • Synthesize Missing Client Contacts for Matters

      This script below will create dummy contacts where the Matter is assigned to a contact that no longer exists. --Some of the Matters are linked to contacts that no longer exist. --This will create dummy contacts from the missing links. INSERT INTO ...
    • Matter Participants: Data Cleanup

      Table Overview Matter Participants are contacts that are related to Matters. They exist in the table: __M_Matters_Participating_Entities They have three primary fields: Field Description Final_Matter_Id The Id of the Matter. Final_Participant_Type ...
    • Synthesize Missing Matters for Documents

      Some systems only allow documents to be linked to matters. These scripts will allow you to restore data into these systems. When Matters No Longer Exist The following script with synthesize matters for document related to matters that no longer ...
    • Create a "Legacy Matter Number" Custom Field

      Some firms rely heavily on Matter Numbers to search for a specific matter. Sometimes when they migrate to a new system it can't replicate the automatic numbering system from their old system so they want to renumber all their matters to a new scheme ...