0

I've been working for about two years within Salesforce Marketing Cloud, but haven't had the need to utilize anything outside of AMPScript, HTML, and CSS as I mostly just build and deploy emails with minimal Data Extension tampering. The Data Extensions are currently being created through a less-than-ideal process which occasionally requires a last-minute change to a field's content. In this scenario, a URL that is the same for all recipients of the email needs to change to something else. I have a template that pulls that URL into the email using AMPScript, and I wanted to find a way to keep the template as is so I don't need to change anything. The goal is to have some code that will overwrite this URL with a new one in these rare instances this occurs. I'm relatively new to this and I didn't find anything entirely similar on the site thus far. Here's what I've got based on my current research:

<script runat="server" type="text/javascript">

    Platform.Load("Core","1.1");

    // Initialize Data Extension by Name into a Variable
    var LoadDE = DataExtension.Init("Data_Extension_Name");
    
    // Find URL column and add new URL
    LoadDE.Rows.Update({"Banner URL":"https://new-url.com/",["Banner URL"],["https://old-url.com"]);

</script>

The "Validate Syntax" doesn't throw any errors, but if I run it, nothing changes. I feel this is way simpler than some of the other questions on here, but as a newbie to SSJS I'm hoping on the right track, however any information to direct me towards a proper solution is welcome if I'm heading in the wrong direction. Trying to learn by doing, thanks in advance!

1 Answer 1

1

I think you are missing the closed } in your Rows.Update line before the first comma.

https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-programmatic-content.meta/mc-programmatic-content/ssjs_dataExtensionRowsUpdate.htm

This would be the "core" function.

As an alternative you could also go for the "Platform" function which is closer to AMPScript syntax.

https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-programmatic-content.meta/mc-programmatic-content/ssjs_platformDataExtensionUpdateData.htm

1
  • Thanks for the response! You were correct in that I was missing the } - good eye! I was driving myself crazy thinking the problem might have been a bigger one. However I ran it and it didn't seem to work. I decided to give your second, or alternative response, a try and it worked like a dream. Thank you - I've upvoted (though I'm new so it won't show) and marked as answered. Appreciate it!
    – Eduardo
    Oct 13, 2020 at 11:37

You must log in to answer this question.

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