Skip to main content
deleted 62 characters in body
Source Link

I am trying to use SSJS to retrieve the DE names of all DE's in a particular folder (folderid = 14273, not sure if that needs to be in quotations), and save them in an upsert DE (DE name = DEDEDede). The below script runs successfully in automation studio but when I check back DEDEDede, no rows are generated. I also tried testing by hardcoding the name of just 1 DE in the folder but that didn't work either.

The upsert DE has 2 fields, Name (primary key, text, max 300 characters) and CreatedDate (date, nullable)

<script runat="server">
   Platform.Load("core""Core", "1""1.1.1");
 
   var apifolderId = new"14273"; Script.Util.WSProxy(); 
   var folderIDtargetDEName = "14273";"Dede";  
   var targetDEdataExtensions = Platform.Function.DataExtension.InitRetrieve("DEDE"{Property:"CategoryID", SimpleOperator:"equals", Value:folderId}); 

try {
   for (var reqi = api0; i < dataExtensions.retrieve("DataExtension",length; ["Name"],i++) {
       var Property:deName "CategoryID",
= dataExtensions[i].Name;   
     SimpleOperator: "equals", 
       var Value:rowsAffected folderID= Platform.Function.UpsertData(
    });

    if (req.Results.length > 0)targetDEName, {
        for (var i = 0; i < req.Results.length; i++) {
           ['Name'], var deName = req.Results[i].Name;
            var data = [
     
           [deName], {
                    Name: deName
           ['CreatedDate'],     }          
           [null] ];

            targetDE.Rows.Upsert(["Name"], data);
        }   
    }
} catch (error) {);
   }
</script>
  

I am trying to use SSJS to retrieve the DE names of all DE's in a particular folder (folderid = 14273), and save them in an upsert DE (DE name = DEDE). The below script runs successfully in automation studio but when I check back DEDE, no rows are generated. I also tried testing by hardcoding the name of just 1 DE in the folder but that didn't work either.

The upsert DE has 2 fields, Name (primary key, text, max 300 characters) and CreatedDate (date, nullable)

<script runat="server">
Platform.Load("core", "1");
 
var api = new Script.Util.WSProxy();
var folderID = "14273"; 
var targetDE = DataExtension.Init("DEDE"); 

try {
    var req = api.retrieve("DataExtension", ["Name"], {
        Property: "CategoryID",
        SimpleOperator: "equals",
        Value: folderID
    });

    if (req.Results.length > 0) {
        for (var i = 0; i < req.Results.length; i++) {
            var deName = req.Results[i].Name;
            var data = [
                {
                    Name: deName
                }
            ];

            targetDE.Rows.Upsert(["Name"], data);
        }
    }
} catch (error) {
}
 

I am trying to use SSJS to retrieve the DE names of all DE's in a particular folder (folderid = 14273, not sure if that needs to be in quotations), and save them in an upsert DE (DE name = Dede). The below script runs successfully in automation studio but when I check back Dede, no rows are generated. I also tried testing by hardcoding the name of just 1 DE in the folder but that didn't work either.

The upsert DE has 2 fields, Name (primary key, text, max 300 characters) and CreatedDate (date, nullable)

<script runat="server">
   Platform.Load("Core", "1.1.1");
   var folderId = "14273";  
   var targetDEName = "Dede";  
   var dataExtensions = Platform.Function.DataExtension.Retrieve({Property:"CategoryID", SimpleOperator:"equals", Value:folderId});

   for (var i = 0; i < dataExtensions.length; i++) {
       var deName = dataExtensions[i].Name;   
       
       var rowsAffected = Platform.Function.UpsertData(
           targetDEName,                  
           ['Name'],                        
           [deName],                      
           ['CreatedDate'],               
           [null]                         
       );
   }
</script>
 
Source Link

Create an upsert DE with SSJS

I am trying to use SSJS to retrieve the DE names of all DE's in a particular folder (folderid = 14273), and save them in an upsert DE (DE name = DEDE). The below script runs successfully in automation studio but when I check back DEDE, no rows are generated. I also tried testing by hardcoding the name of just 1 DE in the folder but that didn't work either.

The upsert DE has 2 fields, Name (primary key, text, max 300 characters) and CreatedDate (date, nullable)

<script runat="server">
Platform.Load("core", "1");

var api = new Script.Util.WSProxy();
var folderID = "14273"; 
var targetDE = DataExtension.Init("DEDE"); 

try {
    var req = api.retrieve("DataExtension", ["Name"], {
        Property: "CategoryID",
        SimpleOperator: "equals",
        Value: folderID
    });

    if (req.Results.length > 0) {
        for (var i = 0; i < req.Results.length; i++) {
            var deName = req.Results[i].Name;
            var data = [
                {
                    Name: deName
                }
            ];

            targetDE.Rows.Upsert(["Name"], data);
        }
    }
} catch (error) {
}