How to Copy Vendor emails from TO and CC to the Email Field in Dynamics GP

Many users user the Vendor card field To and CC fields, and Fidesic uses

You can use the below SQL Script to move your vendor addresses from the To and CC fields to the Email Field in GP. This field is what Fidesic uses for vendor notifications. 

 

Note: Do not run this script multiple times. 

 

--Do not run this script multiple times as it will keep adding TO and CC addresses to the email field. 

UPDATE SY01200
SET INET1 = CASE 
                WHEN LTRIM(RTRIM(ISNULL(CAST(INET1 AS varchar(max)), ''))) = '' THEN ''
                ELSE RTRIM(LTRIM(ISNULL(CAST(INET1 AS varchar(max)), ''))) + 
                     CASE 
                         WHEN LTRIM(RTRIM(ISNULL(CAST(EmailToAddress AS varchar(max)), ''))) <> '' 
                         OR LTRIM(RTRIM(ISNULL(CAST(EmailCCAddress AS varchar(max)), ''))) <> '' THEN '; ' 
                         ELSE ''
                     END
            END +
            CASE 
                WHEN LTRIM(RTRIM(ISNULL(CAST(EmailToAddress AS varchar(max)), ''))) <> '' THEN LTRIM(RTRIM(CAST(EmailToAddress AS varchar(max))))
                ELSE ''
            END +
            CASE 
                WHEN LTRIM(RTRIM(ISNULL(CAST(EmailToAddress AS varchar(max)), ''))) <> '' 
                 AND LTRIM(RTRIM(ISNULL(CAST(EmailCCAddress AS varchar(max)), ''))) <> '' THEN '; '
                ELSE ''
            END +
            CASE 
                WHEN LTRIM(RTRIM(ISNULL(CAST(EmailCCAddress AS varchar(max)), ''))) <> '' THEN LTRIM(RTRIM(CAST(EmailCCAddress AS varchar(max))))
                ELSE ''
            END
WHERE Master_Type = 'VEN'
AND (DATALENGTH(EmailToAddress) > 0 OR DATALENGTH(EmailCCAddress) > 0);