After digging, I have found the API object for FilterActivities, and have been able to Perform, Retrieve, etc. from them, but have been unable to Create one from scratch.
I have received the following error when running my script below:
{"message":"An error occurred when attempting to evaluate a SetObjectProperty function call. See inner exception for details." "description":"ExactTarget.OMM.FunctionExecutionException: An error occurred when attempting to evaluate a SetObjectProperty function call. See inner exception for details.
Error Code: OMM_FUNC_EXEC_ERROR
- from Jint -->
--- inner exception 1---
System.Exception: Invalid property name.
Object Type: ExactTarget.Integration.WSDL.DataExtension
Property Name: ObjectType - from OMMCommon"}
Below is my SSJS making the API call:
<script runat="server">
Platform.Load("core", "1");
try {
// Data Extension Definitions
var i = 0;
var masterDE = '****';
var onDeck = '****';
// Initiate onDeckDE for Lookup
var onDeckDE = DataExtension.Init(onDeck);
// Gather all Rows from OnDeckDE
var rows = onDeckDE.Rows.Lookup(["Status"], ["Active"]);
// For Loop to create Filters from OnDeck
if (rows !== null) {
for (i in rows) {
// Set Values for Row from OnDeck
var filterName = rows[i].CampaignCode + '_alt';
var campaignCode = rows[i].CampaignCode;
var status = rows[i].Status;
var macme = rows[i].MACME;
var projectedDate = rows[i].ProjectedDate;
// Retrieve the Filter Definition ObjectID for the Filter Activity Creation
var RetrieveRequest = Platform.Function.CreateObject("RetrieveRequest");
Platform.Function.SetObjectProperty(RetrieveRequest, "ObjectType", "FilterDefinition");
Platform.Function.AddObjectArrayItem(RetrieveRequest, "Properties", "CustomerKey");
Platform.Function.AddObjectArrayItem(RetrieveRequest, "Properties", "ObjectID");
Platform.Function.AddObjectArrayItem(RetrieveRequest, "Properties", "Name");
var SimpleFilterPart = Platform.Function.CreateObject("SimpleFilterPart");
Platform.Function.SetObjectProperty(SimpleFilterPart, "Property", "CustomerKey");
Platform.Function.SetObjectProperty(SimpleFilterPart, "SimpleOperator", "equals");
Platform.Function.AddObjectArrayItem(SimpleFilterPart, "Value", filterName);
Platform.Function.SetObjectProperty(RetrieveRequest, "Filter", SimpleFilterPart);
var s = [0,0];
var FilterDefinition = Platform.Function.InvokeRetrieve(RetrieveRequest, s);
var filterObjID = FilterDefinition[0].ObjectID;
// Retrieve the Destination DE ObjectID for the Filter Activity Creation
var RetrieveRequest = Platform.Function.CreateObject("DataExtension");
Platform.Function.SetObjectProperty(RetrieveRequest, "ObjectType", "DataExtension");
Platform.Function.AddObjectArrayItem(RetrieveRequest, "Properties", "CustomerKey");
Platform.Function.AddObjectArrayItem(RetrieveRequest, "Properties", "ObjectID");
Platform.Function.AddObjectArrayItem(RetrieveRequest, "Properties", "Name");
var SimpleFilterPart = Platform.Function.CreateObject("SimpleFilterPart");
Platform.Function.SetObjectProperty(SimpleFilterPart, "Property", "CustomerKey");
Platform.Function.SetObjectProperty(SimpleFilterPart, "SimpleOperator", "equals");
Platform.Function.AddObjectArrayItem(SimpleFilterPart, "Value", filterName);
Platform.Function.SetObjectProperty(RetrieveRequest, "Filter", SimpleFilterPart);
var t = [0,0];
var dataExtensionRR = Platform.Function.InvokeRetrieve(RetrieveRequest, t);
var deObjID = dataExtensionRR[0].ObjectID;
// Retrieve the Source DE ObjectID for the Filter Activity Creation
var RetrieveRequest = Platform.Function.CreateObject("DataExtension");
Platform.Function.SetObjectProperty(RetrieveRequest, "ObjectType", "DataExtension");
Platform.Function.AddObjectArrayItem(RetrieveRequest, "Properties", "CustomerKey");
Platform.Function.AddObjectArrayItem(RetrieveRequest, "Properties", "ObjectID");
Platform.Function.AddObjectArrayItem(RetrieveRequest, "Properties", "Name");
var SimpleFilterPart = Platform.Function.CreateObject("SimpleFilterPart");
Platform.Function.SetObjectProperty(SimpleFilterPart, "Property", "CustomerKey");
Platform.Function.SetObjectProperty(SimpleFilterPart, "SimpleOperator", "equals");
Platform.Function.AddObjectArrayItem(SimpleFilterPart, "Value", masterDE);
Platform.Function.SetObjectProperty(RetrieveRequest, "Filter", SimpleFilterPart);
var u = [0,0];
var sourcedataExtensionRR = Platform.Function.InvokeRetrieve(RetrieveRequest, u);
var sourcedeObjID = sourcedataExtensionRR[0].ObjectID;
// Build the Filter Activity
var obj = Platform.Function.CreateObject("FilterActivity");
Platform.Function.SetObjectProperty(obj, "FilterActivityID", filterName);
Platform.Function.SetObjectProperty(obj, "FilterDefinitionID", FilterobjID);
Platform.Function.SetObjectProperty(obj, "DestinationObjectID", filterName);
Platform.Function.SetObjectProperty(obj, "SourceObjectID", sourcedeObjID);
Platform.Function.SetObjectProperty(obj, "CustomerKey", filterName);
Platform.Function.SetObjectProperty(obj, "Name", filterName);
var p = [0,0];
var CreateResults = Platform.Function.InvokeCreate(obj, p, null);
var message = p[0];
var errorCode = p[1];
Write('<br />message: ' + message + '<br />errorCode: ' + errorCode + '<br />');
}
}
}catch(err) {
Write(Stringify(err));
}
</script>
Any idea what I am doing wrong? Judging from the sparse documentation on it, this should work...
var RetrieveRequest = Platform.Function.CreateObject("DataExtension");
should bevar RetrieveRequest = Platform.Function.CreateObject("RetrieveRequest");
-- in both instances.