0

I have folder containing multiple emails that share a common block. Is there any way I could build a SSJS script inside automation studio that would automatically change this specific block from all the emails inside of that specific folder?

1 Answer 1

1

This can be a sum of many parts. We probably cannot write the full code for you, but I can give you some indication on what works and what doesn't.

  • First of all set up: You could just build one central block that you pull in with reference content or ContentblockByKey() by all your relevant emails; now you just need to update one block. Maybe that's what you meant by "common block";

  • A block is an asset in API terms, and yes you can write SSJS script that targets Content Builder REST API and updates an asset, including the content attribute.

  • Emails as entities accept your changes. Meaning if you literally just want to update emails, you are done, limit: unless they are already approved.

  • Approved emails, you won't be changing via Script. And to my knowledge, you cannot withdraw emails via API (you can just turn approvals off generally, and that doesn't sound like something you'd wanna do constantly).

  • If your intention is to update emails that are already in running journeys (technically speaking: they are in published triggered sends) that will not work just by email update. You'll have to "refresh" the TriggeredSendDefininitions (meaning: pause,publish,restart as you would in the UI.)

  • Same for active transactional sends, but simpler. They do not accept changes in a email directly. You have to update the transactional send itself to make it accept a change. Here the refresh can be achieved via the transactional API, just PATCHing the status attribute to "Active" should be all you need, even if it's already "Active".

The SOAP API part can actually be simplified in SSJS by using WSProxy and performing the pause,publish,restart in sequence like so:

<script type="javascript" runat="server">
Platform.Load("core",1);
var prox = new Script.Util.WSProxy();

// necessary variables defined here;

 prox.resetClientIds();
 prox.setClientId({ "ID": businessUnit })

var resultPause = prox.updateItem(
   "TriggeredSendDefinition", 
    {
         "CustomerKey": customerKey, 
         "TriggeredSendStatus": "Inactive"
     }
);
var resultPublish = prox.updateItem(
    "TriggeredSendDefinition", 
    {
    "CustomerKey": customerKey, 
    "RefreshContent": true
    }
);
var resultRestart = prox.updateItem(
    "TriggeredSendDefinition", 
    {
    "CustomerKey": customerKey, 
    "TriggeredSendStatus": "Active"
    }
);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .