Update an Automation verified

Learn how to update an Automation in Salesforce Marketing Cloud (SFMC) with SSJS (server-side JavaScript). Code snippets include the WSProxy method.

WSProxy

var api = new Script.Util.WSProxy();

api.setClientId({
    "ID": Platform.Function.AuthenticatedMemberID(),
    "UserID": Platform.Function.AuthenticatedEmployeeID()
});

var options = {
    SaveOptions: [
        {
            PropertyName: '*',
            SaveAction: 'UpdateAdd'
        }
    ]
};

var config = {
    Name: "MyAutomation",
    CustomerKey: "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
    Description: "Updated"
};

var result = api.updateItem("Automation", config, options);
<script runat="server">

    Platform.Load("core", "1");

    var api = new Script.Util.WSProxy();

    api.setClientId({
        "ID": Platform.Function.AuthenticatedMemberID(),
        "UserID": Platform.Function.AuthenticatedEmployeeID()
    });
	
	try {

        var options = {
            SaveOptions: [
                {
                    PropertyName: '*',
                    SaveAction: 'UpdateAdd'
                }
            ]
        };

        var config = {
            Name: "MyAutomation",
            CustomerKey: "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
            Description: "Updated"
        };

        var result = api.updateItem("Automation", config, options);

        Write(Stringify(result));
		
	} catch(error) {
        Write(Stringify(error));
    }	

</script>
{
    "Status": "OK",
    "RequestID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
    "Results": [
        {
            "Object": {
                "Schedule": null,
                "AutomationTasks": null,
                "IsActive": true,
                "AutomationSource": null,
                "Status": 0,
                "Notifications": null,
                "ScheduledTime": "0001-01-01T00:00:00.000",
                "AutomationType": "Scheduled",
                "UpdateModified": false,
                "LastRunInstanceID": null,
                "CreatedBy": 0,
                "CategoryID": null,
                "LastRunTime": "0001-01-01T00:00:00.000",
                "LastSaveDate": "0001-01-01T00:00:00.000",
                "ModifiedBy": 0,
                "RecurrenceID": null,
                "LastSavedBy": 0,
                "InteractionObjectID": null,
                "Name": "MyAutomation",
                "Description": "Updated",
                "Keyword": null,
                "Client": {
                    "ID": 100000000,
                    "ClientID1": 0,
                    "PartnerClientKey": null,
                    "UserID": 100000000,
                    "PartnerUserKey": null,
                    "CreatedBy": 0,
                    "ModifiedBy": 0,
                    "EnterpriseID": 0,
                    "CustomerKey": null,
                    "CustomerID": null
                },
                "PartnerKey": null,
                "PartnerProperties": [
                    {
                        "Name": "AutomationType",
                        "Value": "Scheduled"
                    }
                ],
                "CreatedDate": "0001-01-01T00:00:00.000",
                "ModifiedDate": null,
                "ID": 0,
                "ObjectID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
                "CustomerKey": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
                "Owner": null,
                "CorrelationID": null,
                "ObjectState": null,
                "IsPlatformObject": false
            },
            "UpdateResults": null,
            "ParentPropertyName": null,
            "StatusCode": "OK",
            "StatusMessage": "Program updated",
            "OrdinalID": 0,
            "ErrorCode": 0,
            "RequestID": null,
            "ConversationID": null,
            "OverallStatusCode": null,
            "RequestType": "Synchronous",
            "ResultType": null,
            "ResultDetailXML": null
        }
    ]
}

WARNING

setClientId is required to avoid the "Updated Access was denied!" error.

WARNING

CustomerKey is required to update the Automation, although, when omitted, the method doesn't return any errors.

Reference

Ressources and references related to the current methods.

Official documentation
SOAP object

Help me turn coffee into code

This website is provided to you free of charge. However, a lot of time and effort are spent to write, test and mainain the code. Please consider supporting my work by buying me a cup of coffee.

Last Updated: