This script is part of the SQL Scripts for Microsoft Dynamics GP where I will be posting the scripts I wrote against Microsoft Dynamics GP over the 19 years before I stopped working with Dynamics GP.
This script will change en masse the email message assigned to workflow steps; it was created for a client after they created new messages for each workflow type and had a lot of workflow steps which needed to be assigned to the new email message.
The two parameters to set are highlighted; care needs to be taken, especially with the @EmailMessageID as there is no validation in the script.
/*
Created by Ian Grieve of azurecurve | Ramblings of an IT Professional (http://www.azurecurve.co.uk)
This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int).
*/
DECLARE @Workflow_Type_Name VARCHAR(40) = 'Purchase Requisition Approval'
DECLARE @EmailMessageID VARCHAR(30) = 'AZRCRV POREQ ASSIGNED'
UPDATE
['Workflow Step Table']
SET
EmailMessageID = @EmailMessageID
,Workflow_Step_Send_Email = 1
FROM
WF100003 AS ['Workflow Step Table'] --Workflow Step Table (WF100003)
INNER JOIN
WF100002 AS ['Workflow Master'] --Workflow Master (WF100002)
ON
['Workflow Master'].Workflow_Name = ['Workflow Step Table'].Workflow_Name
WHERE
['Workflow Master'].Workflow_Type_Name = @Workflow_Type_Name
AND
['Workflow Step Table'].Workflow_Step_Send_Email = 0
GO