Skip to main content
edited tags
Link
zuzannamj
  • 14.5k
  • 3
  • 27
  • 56
deleted 810 characters in body
Source Link
    <script runat="server">runat='server'>
        Platform.Load("core", "1.1.1");
          
        /* CREATE EMAIL SEND DEFINITION */
 Get External/CustomerKey of ObjectID based on DE Name
function getDEobjectID(deName){
var prox = new Script.Util.WSProxy();
        var guidcols = Platform.Function.GUID();["ObjectID"];
        var namefilter = "ESD_" + guid;{
        var yourSCKey =Property: "SC_Key";"Name",
        var yourDECustKey =SimpleOperator: "DE_Key";"equals",
        var yourExDEID =Value: "ExDE_Key";deName
        var yourEmailCustomerKey}; = "Email_Key";
         
var yourEmailNameresult = "EmailName";
      prox.retrieve("DataExtension", cols, filter);
        var esdobjectID = {
           result.Results[0].ObjectID; "Name": name,
            "CustomerKey": guid,
            "SendClassification"Write("ObjectID: {
             " + objectID "CustomerKey":+ yourSCKey"<br><br>");
           
return objectID;
},;
            "SendDefinitionList": [{
                "CustomObjectID": yourDECustKey,
              var deName "DataSourceTypeID":= "CustomObject","DEName";
              var objectID "List":= {getDEobjectID(deName);
                     "ListName": "All Subscribers",
                     "CustomerKey": "XXXXXXXXXXX",
                  var prox = "ListClassification":new "PublicationList"Script.Util.WSProxy();
                }
    var esd = {
    "Name": }"SOAP_ESD_test1",
           "SendDefinitionList": [{
                "CustomObjectID": yourExDEIDobjectID,
                "DataSourceTypeID": "CustomObject",
                "SendDefinitionListType": "ExclusionList"
            }],
           
            "Email": {
                "CustomerKey""ID": yourEmailCustomerKey,6499
                "Name": yourEmailName},
                "IsApproved""SendClassification": true,{
                "Subject""CustomerKey": name,
       "Default Commercial"
            },
            "IsMultipart": true
        };
        
         
try {
          
        var res = prox.createItem("EmailSendDefinition", esd);
        Write('Response: ' + Stringify(res) + '<br><br>');
          
        var esdCustKey = res.Results[0].Object.CustomerKey
        Platform.Response.Write('ESDKey: ' + esdCustKey);
        
        } catch (e) {
         Write(Stringify(e));
        };
        
   </script>
    
 
    <script runat="server">
        Platform.Load("core", "1.1.1");
          
        /* CREATE EMAIL SEND DEFINITION */
         var prox = new Script.Util.WSProxy();
        var guid = Platform.Function.GUID();
        var name = "ESD_" + guid;
        var yourSCKey = "SC_Key";
        var yourDECustKey = "DE_Key";
        var yourExDEID = "ExDE_Key";
        var yourEmailCustomerKey = "Email_Key";
        var yourEmailName = "EmailName";
        
        var esd = {
            "Name": name,
            "CustomerKey": guid,
            "SendClassification": {
                "CustomerKey": yourSCKey
            },
            "SendDefinitionList": [{
                "CustomObjectID": yourDECustKey,
                "DataSourceTypeID": "CustomObject",
                "List": {
                     "ListName": "All Subscribers",
                     "CustomerKey": "XXXXXXXXXXX",
                     "ListClassification": "PublicationList"
                }
            },
            {
                "CustomObjectID": yourExDEID,
                "DataSourceTypeID": "CustomObject",
                "SendDefinitionListType": "ExclusionList"
            }],
           
            "Email": {
                "CustomerKey": yourEmailCustomerKey,
                "Name": yourEmailName,
                "IsApproved": true,
                "Subject": name,
        
            },
            "IsMultipart": true
        }
        
        try{
          
        var res = prox.createItem("EmailSendDefinition", esd);
        Write('Response: ' + Stringify(res) + '<br><br>');
          
        var esdCustKey = res.Results[0].Object.CustomerKey
        Platform.Response.Write('ESDKey: ' + esdCustKey);
        
        } catch(e) {
         Write(Stringify(e));
        };
        
   </script>
    
 
<script runat='server'>
Platform.Load("core", "1.1.1");

//Get External/CustomerKey of ObjectID based on DE Name
function getDEobjectID(deName){
var prox = new Script.Util.WSProxy();
var cols = ["ObjectID"];
var filter = {
    Property: "Name",
    SimpleOperator: "equals",
    Value: deName
};  
   
var result = prox.retrieve("DataExtension", cols, filter);
var objectID = result.Results[0].ObjectID;  

Write("ObjectID: " + objectID + "<br><br>");

return objectID;
};


var deName = "DEName";
var objectID = getDEobjectID(deName);


var prox = new Script.Util.WSProxy();
  
var esd = {
    "Name": "SOAP_ESD_test1",
    "SendDefinitionList": [{
        "CustomObjectID": objectID,
        "DataSourceTypeID": "CustomObject"
    }],
    "Email": {
        "ID": 6499
    },
    "SendClassification": {
        "CustomerKey": "Default Commercial"
    }
};

 
try {

    var res = prox.createItem("EmailSendDefinition", esd);
    Write('Response: ' + Stringify(res) + '<br><br>');

} catch (e) {
    Write(Stringify(e));
}

</script>
Source Link

Creating an EmailSendDefinition with WSProxy

I'm looking to create an Email Send Definition via WSProxy. I am trying to mirror the SOAP Envelope for my proxy script.

I am getting an error when trying to create it; Error Code: 2...

    <script runat="server">
        Platform.Load("core", "1.1.1");
          
        /* CREATE EMAIL SEND DEFINITION */
        var prox = new Script.Util.WSProxy();
        var guid = Platform.Function.GUID();
        var name = "ESD_" + guid;
        var yourSCKey = "SC_Key";
        var yourDECustKey = "DE_Key";
        var yourExDEID = "ExDE_Key";
        var yourEmailCustomerKey = "Email_Key";
        var yourEmailName = "EmailName";
        
        var esd = {
            "Name": name,
            "CustomerKey": guid,
            "SendClassification": {
                "CustomerKey": yourSCKey
            },
            "SendDefinitionList": [{
                "CustomObjectID": yourDECustKey,
                "DataSourceTypeID": "CustomObject",
                "List": {
                     "ListName": "All Subscribers",
                     "CustomerKey": "XXXXXXXXXXX",
                     "ListClassification": "PublicationList"
                }
            },
            {
                "CustomObjectID": yourExDEID,
                "DataSourceTypeID": "CustomObject",
                "SendDefinitionListType": "ExclusionList"
            }],
           
            "Email": {
                "CustomerKey": yourEmailCustomerKey,
                "Name": yourEmailName,
                "IsApproved": true,
                "Subject": name,
        
            },
            "IsMultipart": true
        }
        
        try{
          
        var res = prox.createItem("EmailSendDefinition", esd);
        Write('Response: ' + Stringify(res) + '<br><br>');
          
        var esdCustKey = res.Results[0].Object.CustomerKey
        Platform.Response.Write('ESDKey: ' + esdCustKey);
        
        } catch(e) {
         Write(Stringify(e));
        };
        
   </script>