Skip to main content
added 35 characters in body
Source Link

Little guidance would help me !

Little guidance would help me !

added 72 characters in body
Source Link

Tried different if conditions still its not updating col2 values in the DE2

<script runat="server">

Platform.Load("core", "1.1.1");

var records = retrieveAllRecords("de1");

Write(Stringify(records));
  Write(records[1].ServiceKey);
Write(records[1].Alias);
 
function retrieveFieldNames(name) {

    var attr = DataExtension.Retrieve({ Property: "Name", SimpleOperator: "equals", Value: name });

    var de = DataExtension.Init(attr[1].CustomerKey);

    var fields = de.Fields.Retrieve();

    fields.sort(function (a, b) { return (a.Ordinal > b.Ordinal) ? 2 : -2 });

    var out = [];

    for (k in fields) {
        out = out.concat(fields[k].Name);
    }

    return out;

}

function retrieveAllRecords(name) {

    var prox = new Script.Util.WSProxy();

    var cols = retrieveFieldNames(name);

    var config = {
        name: name,
        cols: cols,
    }

    var records = [],
        moreData = true,
        reqID = data = null;

    while (moreData) {

        moreData = false;

        if (reqID == null) {
            data = prox.retrieve("DataExtensionObject[" + config.name + "]", config.cols);
        } else {
            data = prox.getNextBatch("DataExtensionObject[" + config.name + "]", reqID);
        }

        if (data != null) {
            moreData = data.HasMoreRows;
            reqID = data.RequestID;
            for (var i = 0; i < data.Results.length; i++) {
                var result_list = data.Results[i].Properties;
                var obj = {};
                for (k in result_list) {
                    var key = result_list[k].Name;
                    var val = result_list[k].Value;
                   //var encodedStr = Platform.Function.Base64Encode(val); // encoding as argument may include ' or " chars

   var TestDE = DataExtension.Init("De2");
   
                try{
        
    var amp = '%' + "%[ Output(Concat(EncryptSymmetric('" + val + "', 'AES',";
         amp += "'enkey_password', @null,";
         amp += "'enkey_salt', @null,";
         amp += "'enkey_vector', @null)))";
         amp += ']%' + '%';
         
         if(key == "ServiceKey"){
          var val = Platform.Function.TreatAsContent(amp);
           var result = TestDE.Rows.Add({"ServiceLicenseKey""ServiceKey":val}); 
         }
         if(key != "ServiceKey")/***it is not working** /
       {
            var result = TestDE.Rows.Add({"Alias":val}); /* the value is not added into the data extension*/
       }
                  }catch(ex){
               Write("An error has occurred: " + Stringify(ex));
        Write("   deObj: " + Stringify(deObj));
        Variable.SetValue("@Result", Stringify(ex));
                  }
                  
                    
                    if (key.indexOf("_") != 0) obj[key] = val;
                    
                                              
                }
                records.push(obj);
            }
        }
    }
    return records;
}
</script>
<script runat="server">

Platform.Load("core", "1.1.1");

var records = retrieveAllRecords("de1");

Write(Stringify(records));
  Write(records[1].ServiceKey);
Write(records[1].Alias);
 
function retrieveFieldNames(name) {

    var attr = DataExtension.Retrieve({ Property: "Name", SimpleOperator: "equals", Value: name });

    var de = DataExtension.Init(attr[1].CustomerKey);

    var fields = de.Fields.Retrieve();

    fields.sort(function (a, b) { return (a.Ordinal > b.Ordinal) ? 2 : -2 });

    var out = [];

    for (k in fields) {
        out = out.concat(fields[k].Name);
    }

    return out;

}

function retrieveAllRecords(name) {

    var prox = new Script.Util.WSProxy();

    var cols = retrieveFieldNames(name);

    var config = {
        name: name,
        cols: cols,
    }

    var records = [],
        moreData = true,
        reqID = data = null;

    while (moreData) {

        moreData = false;

        if (reqID == null) {
            data = prox.retrieve("DataExtensionObject[" + config.name + "]", config.cols);
        } else {
            data = prox.getNextBatch("DataExtensionObject[" + config.name + "]", reqID);
        }

        if (data != null) {
            moreData = data.HasMoreRows;
            reqID = data.RequestID;
            for (var i = 0; i < data.Results.length; i++) {
                var result_list = data.Results[i].Properties;
                var obj = {};
                for (k in result_list) {
                    var key = result_list[k].Name;
                    var val = result_list[k].Value;
                   //var encodedStr = Platform.Function.Base64Encode(val); // encoding as argument may include ' or " chars

   var TestDE = DataExtension.Init("De2");
   
                try{
        
    var amp = '%' + "%[ Output(Concat(EncryptSymmetric('" + val + "', 'AES',";
         amp += "'enkey_password', @null,";
         amp += "'enkey_salt', @null,";
         amp += "'enkey_vector', @null)))";
         amp += ']%' + '%';
         
         if(key == "ServiceKey"){
          var val = Platform.Function.TreatAsContent(amp);
           var result = TestDE.Rows.Add({"ServiceLicenseKey":val}); 
         }
         if(key != "ServiceKey")/***it is not working** /
       {
            var result = TestDE.Rows.Add({"Alias":val}); /* the value is not added into the data extension*/
       }
                  }catch(ex){
               Write("An error has occurred: " + Stringify(ex));
        Write("   deObj: " + Stringify(deObj));
        Variable.SetValue("@Result", Stringify(ex));
                  }
                  
                    
                    if (key.indexOf("_") != 0) obj[key] = val;
                    
                                              
                }
                records.push(obj);
            }
        }
    }
    return records;
}
</script>

Tried different if conditions still its not updating col2 values in the DE2

<script runat="server">

Platform.Load("core", "1.1.1");

var records = retrieveAllRecords("de1");

Write(Stringify(records));
  Write(records[1].ServiceKey);
Write(records[1].Alias);
 
function retrieveFieldNames(name) {

    var attr = DataExtension.Retrieve({ Property: "Name", SimpleOperator: "equals", Value: name });

    var de = DataExtension.Init(attr[1].CustomerKey);

    var fields = de.Fields.Retrieve();

    fields.sort(function (a, b) { return (a.Ordinal > b.Ordinal) ? 2 : -2 });

    var out = [];

    for (k in fields) {
        out = out.concat(fields[k].Name);
    }

    return out;

}

function retrieveAllRecords(name) {

    var prox = new Script.Util.WSProxy();

    var cols = retrieveFieldNames(name);

    var config = {
        name: name,
        cols: cols,
    }

    var records = [],
        moreData = true,
        reqID = data = null;

    while (moreData) {

        moreData = false;

        if (reqID == null) {
            data = prox.retrieve("DataExtensionObject[" + config.name + "]", config.cols);
        } else {
            data = prox.getNextBatch("DataExtensionObject[" + config.name + "]", reqID);
        }

        if (data != null) {
            moreData = data.HasMoreRows;
            reqID = data.RequestID;
            for (var i = 0; i < data.Results.length; i++) {
                var result_list = data.Results[i].Properties;
                var obj = {};
                for (k in result_list) {
                    var key = result_list[k].Name;
                    var val = result_list[k].Value;
                   //var encodedStr = Platform.Function.Base64Encode(val); // encoding as argument may include ' or " chars

   var TestDE = DataExtension.Init("De2");
   
                try{
        
    var amp = '%' + "%[ Output(Concat(EncryptSymmetric('" + val + "', 'AES',";
         amp += "'enkey_password', @null,";
         amp += "'enkey_salt', @null,";
         amp += "'enkey_vector', @null)))";
         amp += ']%' + '%';
         
         if(key == "ServiceKey"){
          var val = Platform.Function.TreatAsContent(amp);
           var result = TestDE.Rows.Add({"ServiceKey":val}); 
         }
         if(key != "ServiceKey")/***it is not working** /
       {
            var result = TestDE.Rows.Add({"Alias":val}); /* the value is not added into the data extension*/
       }
                  }catch(ex){
               Write("An error has occurred: " + Stringify(ex));
        Write("   deObj: " + Stringify(deObj));
        Variable.SetValue("@Result", Stringify(ex));
                  }
                  
                    
                    if (key.indexOf("_") != 0) obj[key] = val;
                    
                                              
                }
                records.push(obj);
            }
        }
    }
    return records;
}
</script>
added 408 characters in body
Source Link
Platform.Load("core", "1.1.1");var records = retrieveAllRecords("de1");Write(Stringify(records));Write(records[1].ServiceKey);Write(records[1].Alias);function retrieveFieldNames(name){var attr = DataExtension.Retrieve({ Property: "Name", SimpleOperator: "equals", Value: name});var de = DataExtension.Init(attr[1].CustomerKey);var fields = de.Fields.Retrieve();fields.sort(function(a, b){ return(a.Ordinal > b.Ordinal)? 2:-2});var out = [];for(k in fields){out = out.concat(fields[k].Name);}return out;}function retrieveAllRecords(name){var prox = new Script.Util.WSProxy();var cols = retrieveFieldNames(name);var config ={name: name,cols: cols,}var records = [],moreData = true,reqID = data = null;while(moreData){moreData = false;if(reqID == null){data = prox.retrieve("DataExtensionObject[" + config.name + "]", config.cols);} else{data = prox.getNextBatch("DataExtensionObject[" + config.name + "]", reqID);}if(data!= null){moreData = data.HasMoreRows;reqID = data.RequestID;for(var i = 0; i
<script runat="server">

Platform.Load("core", "1.1.1");

var records = retrieveAllRecords("de1");

Write(Stringify(records));
  Write(records[1].ServiceKey);
Write(records[1].Alias);
 
function retrieveFieldNames(name) {

    var attr = DataExtension.Retrieve({ Property: "Name", SimpleOperator: "equals", Value: name });

    var de = DataExtension.Init(attr[1].CustomerKey);

    var fields = de.Fields.Retrieve();

    fields.sort(function (a, b) { return (a.Ordinal > b.Ordinal) ? 2 : -2 });

    var out = [];

    for (k in fields) {
        out = out.concat(fields[k].Name);
    }

    return out;

}

function retrieveAllRecords(name) {

    var prox = new Script.Util.WSProxy();

    var cols = retrieveFieldNames(name);

    var config = {
        name: name,
        cols: cols,
    }

    var records = [],
        moreData = true,
        reqID = data = null;

    while (moreData) {

        moreData = false;

        if (reqID == null) {
            data = prox.retrieve("DataExtensionObject[" + config.name + "]", config.cols);
        } else {
            data = prox.getNextBatch("DataExtensionObject[" + config.name + "]", reqID);
        }

        if (data != null) {
            moreData = data.HasMoreRows;
            reqID = data.RequestID;
            for (var i = 0; i < data.Results.length; i++) {
                var result_list = data.Results[i].Properties;
                var obj = {};
                for (k in result_list) {
                    var key = result_list[k].Name;
                    var val = result_list[k].Value;
                   //var encodedStr = Platform.Function.Base64Encode(val); // encoding as argument may include ' or " chars

   var TestDE = DataExtension.Init("De2");
   
                try{
        
    var amp = '%' + "%[ Output(Concat(EncryptSymmetric('" + val + "', 'AES',";
         amp += "'enkey_password', @null,";
         amp += "'enkey_salt', @null,";
         amp += "'enkey_vector', @null)))";
         amp += ']%' + '%';
         
         if(key == "ServiceKey"){
          var val = Platform.Function.TreatAsContent(amp);
           var result = TestDE.Rows.Add({"ServiceLicenseKey":val}); 
         }
         if(key != "ServiceKey")/***it is not working** /
       {
            var result = TestDE.Rows.Add({"Alias":val}); /* the value is not added into the data extension*/
       }
                  }catch(ex){
               Write("An error has occurred: " + Stringify(ex));
        Write("   deObj: " + Stringify(deObj));
        Variable.SetValue("@Result", Stringify(ex));
                  }
                  
                    
                    if (key.indexOf("_") != 0) obj[key] = val;
                    
                                              
                }
                records.push(obj);
            }
        }
    }
    return records;
}
</script>
Platform.Load("core", "1.1.1");var records = retrieveAllRecords("de1");Write(Stringify(records));Write(records[1].ServiceKey);Write(records[1].Alias);function retrieveFieldNames(name){var attr = DataExtension.Retrieve({ Property: "Name", SimpleOperator: "equals", Value: name});var de = DataExtension.Init(attr[1].CustomerKey);var fields = de.Fields.Retrieve();fields.sort(function(a, b){ return(a.Ordinal > b.Ordinal)? 2:-2});var out = [];for(k in fields){out = out.concat(fields[k].Name);}return out;}function retrieveAllRecords(name){var prox = new Script.Util.WSProxy();var cols = retrieveFieldNames(name);var config ={name: name,cols: cols,}var records = [],moreData = true,reqID = data = null;while(moreData){moreData = false;if(reqID == null){data = prox.retrieve("DataExtensionObject[" + config.name + "]", config.cols);} else{data = prox.getNextBatch("DataExtensionObject[" + config.name + "]", reqID);}if(data!= null){moreData = data.HasMoreRows;reqID = data.RequestID;for(var i = 0; i
<script runat="server">

Platform.Load("core", "1.1.1");

var records = retrieveAllRecords("de1");

Write(Stringify(records));
  Write(records[1].ServiceKey);
Write(records[1].Alias);
 
function retrieveFieldNames(name) {

    var attr = DataExtension.Retrieve({ Property: "Name", SimpleOperator: "equals", Value: name });

    var de = DataExtension.Init(attr[1].CustomerKey);

    var fields = de.Fields.Retrieve();

    fields.sort(function (a, b) { return (a.Ordinal > b.Ordinal) ? 2 : -2 });

    var out = [];

    for (k in fields) {
        out = out.concat(fields[k].Name);
    }

    return out;

}

function retrieveAllRecords(name) {

    var prox = new Script.Util.WSProxy();

    var cols = retrieveFieldNames(name);

    var config = {
        name: name,
        cols: cols,
    }

    var records = [],
        moreData = true,
        reqID = data = null;

    while (moreData) {

        moreData = false;

        if (reqID == null) {
            data = prox.retrieve("DataExtensionObject[" + config.name + "]", config.cols);
        } else {
            data = prox.getNextBatch("DataExtensionObject[" + config.name + "]", reqID);
        }

        if (data != null) {
            moreData = data.HasMoreRows;
            reqID = data.RequestID;
            for (var i = 0; i < data.Results.length; i++) {
                var result_list = data.Results[i].Properties;
                var obj = {};
                for (k in result_list) {
                    var key = result_list[k].Name;
                    var val = result_list[k].Value;
                   //var encodedStr = Platform.Function.Base64Encode(val); // encoding as argument may include ' or " chars

   var TestDE = DataExtension.Init("De2");
   
                try{
        
    var amp = '%' + "%[ Output(Concat(EncryptSymmetric('" + val + "', 'AES',";
         amp += "'enkey_password', @null,";
         amp += "'enkey_salt', @null,";
         amp += "'enkey_vector', @null)))";
         amp += ']%' + '%';
         
         if(key == "ServiceKey"){
          var val = Platform.Function.TreatAsContent(amp);
           var result = TestDE.Rows.Add({"ServiceLicenseKey":val}); 
         }
         if(key != "ServiceKey")/***it is not working** /
       {
            var result = TestDE.Rows.Add({"Alias":val}); /* the value is not added into the data extension*/
       }
                  }catch(ex){
               Write("An error has occurred: " + Stringify(ex));
        Write("   deObj: " + Stringify(deObj));
        Variable.SetValue("@Result", Stringify(ex));
                  }
                  
                    
                    if (key.indexOf("_") != 0) obj[key] = val;
                    
                                              
                }
                records.push(obj);
            }
        }
    }
    return records;
}
</script>
Source Link
Loading