Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Prepare ImportDefinition for Automation (See Automation Below)
- var ImportDefinition = Platform.Function.CreateObject("ImportDefinition");
- Platform.Function.SetObjectProperty(ImportDefinition, "CustomerKey", "SSJS_Import");
- Platform.Function.SetObjectProperty(ImportDefinition, "Name", "SSJS_Import");
- // Build the Automation
- var Automation = Platform.Function.CreateObject("Automation");
- var AutomationName = "TempAutomation";
- Platform.Function.SetObjectProperty(Automation, "Name", AutomationName);
- Platform.Function.SetObjectProperty(Automation, "CustomerKey", AutomationName);
- Platform.Function.SetObjectProperty(Automation, "AutomationType", "scheduled");
- // Build Automation Import Activity (For Step One)
- var ImportActivity = Platform.Function.CreateObject("AutomationActivity");
- Platform.Function.SetObjectProperty(ImportActivity, "Name", "SSJS_Import");
- var APIObject = Platform.Function.CreateObject("APIObject");
- Platform.Function.SetObjectProperty(ImportActivity, "Definition", APIObject);
- Platform.Function.SetObjectProperty(ImportActivity, "ActivityObject", ImportDefinition);
- // Build Automation Task: Task One
- var AutomationTaskOne = Platform.Function.CreateObject("AutomationTask");
- Platform.Function.SetObjectProperty(AutomationTaskOne, "Name", "Task One");
- Platform.Function.AddObjectArrayItem(AutomationTaskOne, "Activities", ImportActivity);
- Platform.Function.AddObjectArrayItem(Automation, "AutomationTasks", AutomationTaskOne);
- // Create Automation
- // The next 4 lines would use the CreateRequest object, but this object is not available in the SSJS platform. Can it be?
- //var CreateRequest = Platform.Function.CreateObject("CreateRequest");
- //var CreateOptions = Platform.Function.CreateObject("CreateOptions");
- //Platform.Function.SetObjectProperty(CreateRequest, "Options", CreateOptions);
- //Platform.Function.AddObjectArrayItem(CreateRequest, "Objects", Automation);
- var StatusAndRequestID = [0,0];
- var CreateResults = Platform.Function.InvokeCreate(Automation, StatusAndRequestID);
- // The line above doesn't play well with API Objects such as Automation or ImportDefinition. It would work with a CreateRequest object, but that object type is unavailable.
- // The code on this page is running behind the scenes on this page and the error at the top is the error for this code. It wants a security descriptor. I think this is inside of the CreateRequest object.
- //Probar esto
- var p = [0,0];
- var status = Platform.Function.InvokeCreate(AutomationTaskOne, p, null);
- var message = p[0];
- var errorCode = p[1];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement