AMPScript
Set @newEvent = Replace(ContentBlockbyID("245740"), @placeholderLink, @replacementLink)
SSJS
var newEvent = Platform.Function.ContentBlockByID("245740").replace(RegExp((placeholderLink), "g"), repalcementLink.substring(1, link.length-1));
I have also tried locating the wrapped link to replace it, but that doesn't work either. I am able to write the link in the email to confirm I located the correct link to replace, but it doesn't get replaced, and the same tracking link is still there. (This method works in the preview, but not in the delivered test email)
// locate href to find index position of the link
var hrefIndex = newBlock.indexOf('href="') + 6;
// find the next quote after the href to locate end of link
var hrefEndIndex = newBlock.indexOf('"', hrefIndex);
var linkToReplace = newBlock.substring(hrefIndex, hrefEndIndex)
Write("link to replace: <br />");
Write(linkToReplace);
Write("<br />new link: <br />");
Write(link);
// remove quotes from around new link var, when replacing
newBlock = newBlock.replace(RegExp((linkToReplace)), "g"), link.substring(1, link.length-1));
Using substring to concatenate the link and content leads to a broken link, even in the Preview and Test view
newBlock = newBlock.substring(0, hrefIndex).concat(link.substring(1, link.length-1), newBlock.substring(hrefEndIndex));
I'm ready to utilize ContentBlockByID and supplant all of the placeholder content, yet there is, by all accounts, an issue while supplanting any connections. The connections get supplanted fine in the preview and test views, yet the connections in the conveyed test email actually direct to (https://styloss.com/) the placeholder interface in the first square, instead of the connection that ought to have supplanted it.I think this has something to do with the connection wrapping occurring before the connection can get supplanted. (The association utilizes exclusively marked joins if that has any effect.) The connection substitution takes care of business when I uncheck "Track Clicks" in the Test Send settings. Is something like this conceivable to do, without switching off click following? Is there another arrangement that could work better?