0

I am trying to replicate the standard feature i.e I want to show the Content Builder Templates dynamically inside Custom Activity based on the Folder Selected.

Requirement:

  1. On the Custom Activity UI, I want to show Content Builder Folders.
  2. When Clicked on Folder, display all Templates as Radio Buttons.
  3. When Selected a Template, read the actual Content.

Firstly Is this feasible?

Any suggestions on starting the build.

Currently, I am pulling Content Builder's Content or Code Resource Text Data individually inside an I-framed Cloud Page and Passing it to Custom Activity via Parent.PostMessage function.

1 Answer 1

0

Its certainly feasible - I've been able to replicate some of this functionality before, but might have had a slightly different purpose. I'd start exploring with some of the Asset REST APIs

If the activity UI sits outside of CloudPages/MC you might be able to explore some templating packages and languages that bring this together more neatly. If you're restricted to using Cloudpages for the UI then you might have to get a bit clever with Single-Page Application principles paired with SSJS and/or AMPScript to achieve the same.

You can probably achieve what you're after with the below REST API's to retrieve and render the data:

Get the Folders in the BU (You'll need some logic to expose the correct directory structure):

https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/getCategories.htm

Query and Retrieve the Templates to display back (Pass the CategoryId based on the selected folder as part of your condition):

https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/assetAdvancedQuery.htm

https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/assetSimpleQuery.htm

From experience, theres an attribute in the retrieve calls that provides you the raw HTML to render but you might have to get a bit clever if you want to render with personalization as part of your custom activity

6
  • I have started the build using Content Builder API. Rather than 2 API's, I have iterated on single API call to filter out the required folders. Just wondering is there any sort function based on Last modified date or created date in the Rest API advanced query ? Is there any option to Limit rows returned too ? I tried below but getting field exception. ` "sort": [{ "property": "Created", "direction": "DESC" }] "sort": [{ "property": "Created_Date", "direction": "DESC" }] ` Mar 30, 2021 at 4:28
  • Another Challenging issue is reading the Content of API Response as Text. The Response in the API is Raw HTML without any Escape characters. JSON Parsing is failing. Where as the same API in Postman gives Raw HTML with Escape. Btw, I'm making API call from SSJS. Hope this shouldn't be an issue. Mar 30, 2021 at 7:10
  • You can sort by 'createdDate' and any other attributes the system stores, best to look at the names they're returned as in the response. You can use the Page object to specify how many results you need and to iterate/paginate: "page": { "page":1, "pageSize":50 } Apr 1, 2021 at 1:48
  • For the Text to HTML, i'd probably play around with some functions to escape characters before you parse it, a pretty basic one could look like: function escapeHtml(unsafe) { return unsafe .replace(/&/g, "&amp;") .replace(/</g, "&lt;") .replace(/>/g, "&gt;") .replace(/"/g, "&quot;") .replace(/'/g, "&#039;"); } var cleanResponse = escapeHTML(response); Might have to play around with it given its in SSJS until you can properly escape everything, theres more sophisticated ways to this outside of MC but this should work within SSJS Apr 1, 2021 at 1:51
  • The above replace logic renders well in the UI with Escape Character. But when I actually Parse the Json, its failing. Tried sending to Client JS, output isnt as expected in Json format. {&quot;count&quot;:6,&quot;page&quot;:1,&quot;pageSize&quot;:50,&quot;links&quot;:{},&quot;items&quot;:[{&quot;id&quot;:31762,&quot;customerKey&quot;:&quot;Transactional_Template3&quot;,&quot;assetType&quot;: etc.. Do you have any working Git? im running out of time :( Apr 1, 2021 at 5:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.