Blocking Emails Dynamically

The value of the ‘Block’ action property for the Send Email action may be set dynamically, for example to control the sending of an email based upon the results of a comparison. To have a workflow send an email only if there are any rows in a comparison results table where the Status column has the value ‘Different’, carry out the following steps:

  1. Create an Execute SQL action, with its Source1 parameter set to the comparison results table, and its Result parameter set to a Table dataset named Block Status. Add the following SQL statements to the Execute SQL action’s Statements parameter:

CREATE TABLE Result (BLOCK nvarchar(5))

INSERT INTO Result (BLOCK) VALUES ('True')

UPDATE Result SET BLOCK = 'False' WHERE EXISTS(SELECT * FROM Source1 WHERE STATUS = 'Different')

  1. Use the Extract Fields action to extract the value of the ‘Block’ field from the Block Status dataset into a String dataset named Block Status (String).
  2. Use the Convert Data action to convert the Block Status (String) String dataset into a Boolean dataset named Block.
  3. Use the Block dataset as the value for the Send Email action’s ‘Block’ action property.

Send Email Actions