The script below will append the text 'Created By: {firstName lastName}', 'Created on behalf of: {firstName lastName}', and 'Updated by: {firstName lastName}' to the end of the note description in cases where the user's Email address was changed on the __M_Users table as a result of User Mapping.
In cases where the firm's domain has changed, every user's email address will have changed. In which case the script below will add that information to all notes, which would be redundant for some records. Therefore, you might want to adjust the WHERE clause.
- --Append Created By/Updated By/Created On Behalf Of to Notes
- UPDATE __M_Common_Notes SET Final_Description = CONCAT(Final_Description, CHAR(10), CHAR(10), 'Created By: ', u.Final_FirstName, ' ', u.Final_LastName) FROM __M_Common_Notes n, __M_Users u WHERE 1=1 AND u.Original_Email != u.Final_Email
- AND u.Id = n.Final_Created_By_Id
- UPDATE __M_Common_Notes SET Final_Description = CONCAT(Final_Description, CHAR(10), CHAR(10), 'Created on behalf of: ', u.Final_FirstName, ' ', u.Final_LastName) FROM __M_Common_Notes n, __M_Users u WHERE 1=1 AND u.Original_Email != u.Final_Email
- AND u.Id = n.Final_Created_OnBehalfOf_Id
- UPDATE
- __M_Common_Notes SET Final_Description = CONCAT(Final_Description, CHAR(10), CHAR(10), 'Updated by: ', u.Final_FirstName, ' ', u.Final_LastName) FROM __M_Common_Notes n, __M_Users u WHERE 1=1 AND u.Original_Email != u.Final_Email
- AND u.Id = n.Final_Updated_By_Id