3

I was wondering if anyone has been able to schedule an automation with SSJS yet?

I tried, and given an existing automation "automation", already created in SSJS, I have the script below:

if(automation.Status == 2) {
    // Create Recurrence Definition
    var Recurrence = Platform.Function.CreateObject("DailyRecurrence");
    Platform.Function.SetObjectProperty(Recurrence, "DailyRecurrencePatternType", "Interval")
    Platform.Function.SetObjectProperty(Recurrence, "DayInterval", 1)

    // Create Schedule Definition
    var scheduleDefinitionApiObj = Platform.Function.CreateObject("ScheduleDefinition");
    Platform.Function.SetObjectProperty(scheduleDefinitionApiObj, "CustomerKey", automation.CustomerKey);
    Platform.Function.SetObjectProperty(scheduleDefinitionApiObj, "Name", automation.Name);
    Platform.Function.SetObjectProperty(scheduleDefinitionApiObj, "StartDateTime", "2018-05-30T10:00:00-05:00");
    Platform.Function.SetObjectProperty(scheduleDefinitionApiObj, "EndDateTime", "2018-06-01T10:00:00-05:00");
    Platform.Function.SetObjectProperty(scheduleDefinitionApiObj, "RecurrenceType", "Daily");
    Platform.Function.SetObjectProperty(scheduleDefinitionApiObj, "RecurrenceRangeType", "EndOn");

    Platform.Function.SetObjectProperty(scheduleDefinitionApiObj, "Recurrence", Recurrence);
    Platform.Function.SetObjectProperty(automation, "Schedule", scheduleDefinitionApiObj);
}

However, the last line of this script is giving me the following error:

SetProperty only works for objects in the ExactTarget.Integration.WSDL namespace. Object Type: System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] Property Name: Schedule

I cannot get my head around this. Any help would be greatly appreciated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.