I'm using a landing page with some SSJS to create several shortcut utilities for Marketing Cloud - namely copying data extensions and running single-use queries without having to save them. I've got a form which copies data extensions when you specify which one you want to copy. Users type the name in the box and press submit.
My one problem is that it's using the Data Extension Customer Key to look it up rather than the name. Unfortunately most of are users are only going to know the name and not the customer key. I'm using:
var prox = new Script.Util.WSProxy();
var cols = ["Name","CustomerKey","CategoryID","IsSendable"];
var filter = {
LeftOperand: {
Property: "CustomerKey",
SimpleOperator: "equals",
Value: copyname
},
LogicalOperator: "OR",
RightOperand: {
Property: "Name",
SimpleOperator: "equals",
Value: copyname
}
};
var desc = prox.retrieve("DataExtension", cols, filter);
Followed by
var prox2 = new Script.Util.WSProxy();
var cols2 = ["Client.ID","CustomerKey","DefaultValue","FieldType","IsPrimaryKey","IsRequired","MaxLength","ModifiedDate","Name","ObjectID","Ordinal","Scale"];
var filter2 = {
Property: "DataExtension.CustomerKey",
SimpleOperator: "equals",
Value: copyname
};
var fields = prox2.retrieve("DataExtensionField", cols2, filter2); /* WSProxy Retrieve */
So it's taking the variable from some previous ampscript using GetValue and using that in the WSProxy retrieve as the customer key. However, I want it to look for the name, not the customer key, or at least use the @copyName to find the customer key of that DE, to use in the following code. I've tried the following without success:
- Property: "DataExtension.Name"
- Property: "DataExtensionName"
- Property: "Name"
- Property: "DataExtension.Name"
And I can't get the name from the first retrieve using desc.Results.Name either - it returns null. Can someone help me get this? Alternatively, a block of ampscript to run before the SSJS to get the CustomerKey from the Name would be even easier.