Working within the workflow, I want to dynamically select the template for a Create Email Content.
I am able to do when the name of the template matches exactly a metadata value …
But now I would like to do it when the template STARTS with that metadata value … “2001001_AutoPay_Cancel.OL-template”
I am attempting to create a script to select the name. I am stuck on how I “Search” the list and find a template that starts with “2001001”. I got this far…
var allTemplates = Watch.GetResources(“OL-template”);
Watch.Log(allTemplates, 3);
var myObj = JSON.parse(“[” + allTemplates + “]”);
Watch.Log("template count = " + myObj.length, 3);
var foundTemplate = myObj.find(x => x.name.startsWith(“2001001”));
/*Watch.Log("template found = " + foundTemplate, 3);
*/
The “find” method breaks. Not sure if that is valid, or a better way to achieve this. Any help is appreciated.
Thanks.