I was able to run an automation which is in "scheduled" staus using SSJS, but when I pause it manually (status changed to "Paused") and execute the same script, the automation doesn't run. The script executes without any errors.
I have tried this in Script Activity and a Landing page, but don't know if I am missing something here.
Has anyone come across a similar issue before?
<script runat="server">
Platform.Load("Core","1.1.1");
var automationCustomerKey = "customer-key"
// Search for an automation
var filter = {Property:"CustomerKey",SimpleOperator:"equals",Value:automationCustomerKey};
var automationObject = Program.Retrieve(filter);
// Start automation if not "Running"
if (3 != automationObject[0].Status) {
Write("Current Status: " +automationObject[0].Status+"\n");
var automationPerformed = Program.Init(automationCustomerKey);
automationPerformed.Perform();
}
else {
Write("Current Status: " +automationObject[0].Status);
}
</script>