Loading

Marketing Cloud Pause, Republish, and Restart Triggered Sends in bulk with SSJS

Publiceringsdatum: Feb 15, 2025
Beskrivning

Important Consideration Before Beginning

Triggered Sends take a significant amount of time to re-activate.   This solution should be used with caution as, if you have hundreds/thousands of Triggered Sends, you will see that re-activation of 1000+ Triggered sends may take 30+ minutes to complete.   In the scenario that there are more than 1000 Triggered Sends in the Business Unit context, you will want to make modifications to chunk these requests into smaller segments such as 500 at a time.  It will be necessary to make modifications to this script given the above scenario as the script, as is, does not account for this scenario.

 

In the business unit where you would like to pause, republish, and restart triggered sends, create the following DE: 
 

DE Name: TSRepublish
 

DE External Key: TSRepublish
 

Field NameData TypeLengthPrimary KeyNullableDefault Value
ExternalKeyText254YesNoNot Applicable
torepublishBooleanNot ApplicableNoNoTrue

 

Populate the DE's 'ExternalKey' field with the External Keys of the Triggered Sends which need to be paused, republished, and restarted.
 

Ensure the 'torepublish' field value is 'True' for any Triggered Sends that are intended to be paused, republished, and restarted. 

Create an Automation Studio Script Activity with the following code:

<script runat="server">
 Platform.Load("core", "1.1.1"); 

  var api = new Script.Util.WSProxy();
  var rowstoprocess = DataExtension.Init("TSRepublish").Rows.Lookup(["torepublish"],[1])

   for(j=0; j < rowstoprocess.length; j ++ ) 
    {
      var tskey = rowstoprocess[j].ExternalKey
      var tsd = TriggeredSend.Init(tskey);
      var pause = tsd.Pause();
      var updateObj = {};
      updateObj.CustomerKey = tskey;
      updateObj.RefreshContent = true;
      var publish = tsd.Update(updateObj);
      var start = tsd.Start();
    }
</script>
Lösning

Run the above SSJS via a Script Activity to pause, publish, and restart any Triggered Sends with their external keys present in the 'TSRepublish' DE with a 'torepublish' value of 'True'. 
 

If any Triggered Sends in the 'TSRepublish' DE do not need to be paused, republished, and restarted, update the 'torepublish' value to 'False' for those sends prior to running the Script Activity. 

Knowledge-artikelnummer

000395628

 
Laddar
Salesforce Help | Article