Created
September 15, 2020 23:37
-
-
Save eliotharper/72c5037f7518e47c0d32169ed7ecf671 to your computer and use it in GitHub Desktop.
Creates a backup Data Extension in SFMC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script runat=server> | |
Platform.Load("core", "1"); | |
// create DE | |
var timeStamp = Math.round((new Date()).getTime() / 1000); | |
var deKey = "BACKUP_" + timeStamp; | |
var deName = "Backup DE " + timeStamp; | |
var obj = { | |
CustomerKey : deKey, | |
Name : deName, | |
Fields : [ | |
{ "Name" : "SubscriberKey", "FieldType" : "Text", "IsPrimaryKey" : true, "MaxLength" : 50, "IsRequired" : true }, | |
{ "Name" : "FirstName", "FieldType" : "Text", "MaxLength" : 50 }, | |
{ "Name" : "LastName", "FieldType" : "Text", "MaxLength" : 50 }, | |
{ "Name" : "EmailAddress", "FieldType" : "EmailAddress", "IsRequired" : true } | |
], | |
SendableInfo : { | |
Field : { "Name" : "SubscriberKey", "FieldType" : "Text" }, | |
RelatesOn : "Subscriber Key" | |
} | |
}; | |
var de = DataExtension.Add(obj); | |
// retrieve DE records | |
var sourceDE = DataExtension.Init("MASTER_CUSTOMERS"); | |
var data = sourceDE.Rows.Retrieve(); | |
// add source rows to target DE | |
var targetDE = DataExtension.Init(deKey); | |
targetDE.Rows.Add(data); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment