-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchapter60.amp
More file actions
70 lines (49 loc) · 2.51 KB
/
chapter60.amp
File metadata and controls
70 lines (49 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
%%[
/* Important caveat -
Automation runs only if it's in scheduled state
it should not be paused or running state
execute this with utmost caution
*/
/* Set the Automation Name to retrieve */
SET @automationName = "SOAP_API_Automation"
/* Create the RetrieveRequest object */
SET @retrieveRequest = CreateObject("RetrieveRequest")
/* Specify the object type and properties to retrieve */
SetObjectProperty(@retrieveRequest, "ObjectType", "Automation")
AddObjectArrayItem(@retrieveRequest, "Properties", "Name")
AddObjectArrayItem(@retrieveRequest, "Properties", "CustomerKey")
/* Create and configure the filter for the RetrieveRequest */
SET @filterPart = CreateObject("SimpleFilterPart")
SetObjectProperty(@filterPart, "Property", "Name")
SetObjectProperty(@filterPart, "SimpleOperator", "equals")
AddObjectArrayItem(@filterPart, "Value", @automationName)
SetObjectProperty(@retrieveRequest, "Filter", @filterPart)
/* Invoke the RetrieveRequest */
SET @retrieveResponse = InvokeRetrieve(@retrieveRequest, @statusMessage, @requestId)
/* Retrieve and validate the response */
IF RowCount(@retrieveResponse) > 0 THEN
SET @responseRow = Row(@retrieveResponse, 1) /* Retrieve the first row from the response */
SET @retrievedCustomerKey = Field(@responseRow, "CustomerKey")
SET @name = Field(@responseRow, "Name")
/* Output the name and CustomerKey with user-friendly messages */
OutputLine(Concat("Automation Name: ", @name))
OutputLine(Concat("CustomerKey: ", @retrievedCustomerKey))
/* Create Automation object to start the automation */
SET @automation = CreateObject("Automation")
SET @clientId=CreateObject("ClientID")
SetObjectProperty(@clientId, "ID", AuthenticatedMemberID())
SetObjectProperty(@clientId, "UserID", AuthenticatedEmployeeID())
SetObjectProperty(@automation, "CustomerKey", @retrievedCustomerKey)
SetObjectProperty(@automation, "Client", @clientId)
/* Invoke the 'start' operation on the automation */
SET @statusCode = InvokePerform(@automation, "start", @statusMessage)
/* Handle the status message of the start operation */
IF @statusCode != "OK" THEN
OutputLine(Concat("Failed to start automation. Status Message: ", @statusMessage))
ELSE
OutputLine(@statusMessage)
ENDIF
ELSE
OutputLine("No automation found with the specified name.")
ENDIF
]%%