Unlock the Power of AMPscript SOAP API
Write an AMPScript code block to retrieve Account
%%[
/* Initialize the RetrieveRequest object to fetch Account details by CustomerKey */
SET @accountRetrieveRequest = CreateObject("RetrieveRequest")
SetObjectProperty(@accountRetrieveRequest, "ObjectType", "Account")
AddObjectArrayItem(@accountRetrieveRequest, "Properties", "Address")
AddObjectArrayItem(@accountRetrieveRequest, "Properties", "BusinessName")
AddObjectArrayItem(@accountRetrieveRequest, "Properties", "City")
AddObjectArrayItem(@accountRetrieveRequest, "Properties", "Country")
/* Set up and configure the filter to locate the account using CustomerKey */
SET @customerKeyFilter = CreateObject("SimpleFilterPart")
SetObjectProperty(@customerKeyFilter, "Property", "CustomerKey")
SetObjectProperty(@customerKeyFilter, "SimpleOperator", "equals")
AddObjectArrayItem(@customerKeyFilter, "Value", "xxxxxxxx-5C32-4504-B8FF-xxxxxxxxxxxx") /* Replace with the target CustomerKey */
SetObjectProperty(@accountRetrieveRequest, "Filter", @customerKeyFilter)
/* Execute the RetrieveRequest to fetch account details */
SET @accountResponse = InvokeRetrieve(@accountRetrieveRequest, @retrieveStatus, @retrieveRequestID)
/* Loop through the retrieved account records */
FOR @recordIndex = 1 TO RowCount(@accountResponse) DO
SET @accountRecord = Row(@accountResponse, @recordIndex)
SET @accountAddress = Field(@accountRecord, "Address")
SET @accountBusinessName = Field(@accountRecord, "BusinessName")
SET @accountCity = Field(@accountRecord, "City")
SET @accountCountry = Field(@accountRecord, "Country")
/* Output the account details */
OutputLine(Concat("Address: ", @accountAddress))
OutputLine(Concat("BusinessName: ", @accountBusinessName))
OutputLine(Concat("City: ", @accountCity))
OutputLine(Concat("Country: ", @accountCountry))
NEXT @recordIndex
]%%
Write AMPscript block to retrieve AccountUser
%%[
/* Initialize the RetrieveRequest object to fetch AccountUser details by Client ID */
SET @accountUserRetrieveRequest = CreateObject("RetrieveRequest")
SetObjectProperty(@accountUserRetrieveRequest, "ObjectType", "AccountUser")
AddObjectArrayItem(@accountUserRetrieveRequest, "Properties", "ActiveFlag")
AddObjectArrayItem(@accountUserRetrieveRequest, "Properties", "CustomerKey")
AddObjectArrayItem(@accountUserRetrieveRequest, "Properties", "UserID")
/* Set up and configure the filter to locate the AccountUser using Client ID */
SET @clientIDFilter = CreateObject("SimpleFilterPart")
SetObjectProperty(@clientIDFilter, "Property", "Client.ID")
SetObjectProperty(@clientIDFilter, "SimpleOperator", "equals")
AddObjectArrayItem(@clientIDFilter, "Value", AuthenticatedMemberID()) /* Replace with the target Client ID */
SetObjectProperty(@accountUserRetrieveRequest, "Filter", @clientIDFilter)
/* Execute the RetrieveRequest to fetch AccountUser details */
SET @accountUserResponse = InvokeRetrieve(@accountUserRetrieveRequest, @retrieveStatus, @retrieveRequestID)
/* Output the retrieve status */
OutputLine(Concat("Retrieve Status: ", @retrieveStatus))
/* Check if any records were retrieved */
IF RowCount(@accountUserResponse) > 0 THEN
/* Loop through the retrieved AccountUser records */
FOR @recordIndex = 1 TO RowCount(@accountUserResponse) DO
SET @accountUserRecord = Row(@accountUserResponse, @recordIndex)
SET @activeFlag = Field(@accountUserRecord, "ActiveFlag")
SET @customerKey = Field(@accountUserRecord, "CustomerKey")
SET @userID = Field(@accountUserRecord, "UserID")
/* Output the AccountUser details */
OutputLine(Concat("ActiveFlag: ", @activeFlag))
OutputLine(Concat("CustomerKey: ", @customerKey))
OutputLine(Concat("UserID: ", @userID))
OutputLine(Concat("-------------"))
NEXT @recordIndex
ELSE
/* Output message if no records are found */
OutputLine("No AccountUser records found for the specified Client ID.")
ENDIF
]%%
Write AMPscript block to retrieve Automation
%%[
/* Initialize the RetrieveRequest object to fetch Automation details by Name */
SET @automationRequest = CreateObject("RetrieveRequest")
SetObjectProperty(@automationRequest, "ObjectType", "Automation")
AddObjectArrayItem(@automationRequest, "Properties", "AutomationType")
AddObjectArrayItem(@automationRequest, "Properties", "CustomerKey")
AddObjectArrayItem(@automationRequest, "Properties", "CreatedDate")
AddObjectArrayItem(@automationRequest, "Properties", "Status")
/* Set up and configure the filter to locate the Automation using Name */
SET @automationNameFilter = CreateObject("SimpleFilterPart")
SetObjectProperty(@automationNameFilter, "Property", "Name")
SetObjectProperty(@automationNameFilter, "SimpleOperator", "equals")
AddObjectArrayItem(@automationNameFilter, "Value", "Webinar Confirmation") /* Replace with the target Automation Name */
SetObjectProperty(@automationRequest, "Filter", @automationNameFilter)
/* Execute the RetrieveRequest to fetch Automation details */
SET @automationResult = InvokeRetrieve(@automationRequest, @retrieveStatus, @retrieveRequestID)
/* Output the retrieve status */
OutputLine(Concat("Retrieve Status: ", @retrieveStatus))
/* Check if any records were retrieved */
IF RowCount(@automationResult) > 0 THEN
/* Loop through the retrieved Automation records */
FOR @recordIndex = 1 TO RowCount(@automationResult) DO
SET @automationData = Row(@automationResult, @recordIndex)
SET @automationType = Field(@automationData, "AutomationType")
SET @automationCustomerKey = Field(@automationData, "CustomerKey")
SET @automationCreatedDate = Field(@automationData, "CreatedDate")
SET @automationStatus = Field(@automationData, "Status")
/* Output the Automation details */
OutputLine(Concat("Automation Type: ", @automationType))
OutputLine(Concat("CustomerKey: ", @automationCustomerKey))
OutputLine(Concat("Created Date: ", @automationCreatedDate))
OutputLine(Concat("Status: ", @automationStatus))
OutputLine("-------------")
NEXT @recordIndex
ELSE
/* Output message if no records are found */
OutputLine("No Automation records found for the specified Name.")
ENDIF
]%%
Write AMPscript block to retrieve BounceEvent
%%[
/* Initialize the RetrieveRequest object to fetch BounceEvent details */
SET @bounceEventRequest = CreateObject("RetrieveRequest")
SetObjectProperty(@bounceEventRequest, "ObjectType", "BounceEvent")
AddObjectArrayItem(@bounceEventRequest, "Properties", "BatchID")
AddObjectArrayItem(@bounceEventRequest, "Properties", "BounceCategory")
AddObjectArrayItem(@bounceEventRequest, "Properties", "BounceType")
AddObjectArrayItem(@bounceEventRequest, "Properties", "EventDate")
AddObjectArrayItem(@bounceEventRequest, "Properties", "SendID")
AddObjectArrayItem(@bounceEventRequest, "Properties", "SubscriberKey")
/* Execute the RetrieveRequest to fetch BounceEvent details */
SET @bounceEventResult = InvokeRetrieve(@bounceEventRequest, @retrieveStatus, @retrieveRequestID)
/* Output the retrieve status */
OutputLine(Concat("Retrieve Status: ", @retrieveStatus))
/* Check if any records were retrieved */
IF RowCount(@bounceEventResult) > 0 THEN
/* Loop through the retrieved BounceEvent records */
FOR @recordIndex = 1 TO RowCount(@bounceEventResult) DO
SET @bounceEventData = Row(@bounceEventResult, @recordIndex)
SET @batchID = Field(@bounceEventData, "BatchID")
SET @bounceCategory = Field(@bounceEventData, "BounceCategory")
SET @bounceType = Field(@bounceEventData, "BounceType")
SET @eventDate = Field(@bounceEventData, "EventDate")
SET @sendID = Field(@bounceEventData, "SendID")
SET @subscriberKey = Field(@bounceEventData, "SubscriberKey")
/* Output the BounceEvent details */
OutputLine(Concat("Batch ID: ", @batchID))
OutputLine(Concat("Bounce Category: ", @bounceCategory))
OutputLine(Concat("Bounce Type: ", @bounceType))
OutputLine(Concat("Event Date: ", @eventDate))
OutputLine(Concat("Send ID: ", @sendID))
OutputLine(Concat("Subscriber Key: ", @subscriberKey))
OutputLine("-------------")
NEXT @recordIndex
ELSE
/* Output message if no records are found */
OutputLine("No BounceEvent records found.")
ENDIF
]%%
Write AMPscript block to retrieve ClickEvent
%%[
/* Initialize the RetrieveRequest object to fetch ClickEvent details */
SET @clickEventRequest = CreateObject("RetrieveRequest")
SetObjectProperty(@clickEventRequest, "ObjectType", "ClickEvent")
AddObjectArrayItem(@clickEventRequest, "Properties", "BatchID")
AddObjectArrayItem(@clickEventRequest, "Properties", "URL")
AddObjectArrayItem(@clickEventRequest, "Properties", "URLID")
AddObjectArrayItem(@clickEventRequest, "Properties", "EventDate")
AddObjectArrayItem(@clickEventRequest, "Properties", "SendID")
AddObjectArrayItem(@clickEventRequest, "Properties", "SubscriberKey")
/* Execute the RetrieveRequest to fetch ClickEvent details */
SET @clickEventResult = InvokeRetrieve(@clickEventRequest, @retrieveStatus, @retrieveRequestID)
/* Output the retrieve status */
OutputLine(Concat("Retrieve Status: ", @retrieveStatus))
/* Check if any records were retrieved */
IF RowCount(@clickEventResult) > 0 THEN
/* Loop through the retrieved ClickEvent records */
FOR @recordIndex = 1 TO RowCount(@clickEventResult) DO
SET @clickEventData = Row(@clickEventResult, @recordIndex)
SET @batchID = Field(@clickEventData, "BatchID")
SET @url = Field(@clickEventData, "URL")
SET @urlID = Field(@clickEventData, "URLID")
SET @eventDate = Field(@clickEventData, "EventDate")
SET @sendID = Field(@clickEventData, "SendID")
SET @subscriberKey = Field(@clickEventData, "SubscriberKey")
/* Output the ClickEvent details */
OutputLine(Concat("Batch ID: ", @batchID))
OutputLine(Concat("URL: ", @url))
OutputLine(Concat("URL ID: ", @urlID))
OutputLine(Concat("Event Date: ", @eventDate))
OutputLine(Concat("Send ID: ", @sendID))
OutputLine(Concat("Subscriber Key: ", @subscriberKey))
OutputLine("-------------")
NEXT @recordIndex
ELSE
/* Output message if no records are found */
OutputLine("No ClickEvent records found.")
ENDIF
]%%
Write AMPscript block to retrieve SentEvent
%%[
/* Initialize the RetrieveRequest object to fetch SentEvent details */
SET @sentEventRequest = CreateObject("RetrieveRequest")
SetObjectProperty(@sentEventRequest, "ObjectType", "SentEvent")
AddObjectArrayItem(@sentEventRequest, "Properties", "BatchID")
AddObjectArrayItem(@sentEventRequest, "Properties", "TriggeredSendDefinitionObjectID")
AddObjectArrayItem(@sentEventRequest, "Properties", "EventDate")
AddObjectArrayItem(@sentEventRequest, "Properties", "SendID")
AddObjectArrayItem(@sentEventRequest, "Properties", "SubscriberKey")
/* Execute the RetrieveRequest to fetch SentEvent details */
SET @sentEventResult = InvokeRetrieve(@sentEventRequest, @retrieveStatus, @retrieveRequestID)
/* Output the retrieve status */
OutputLine(Concat("Retrieve Status: ", @retrieveStatus))
/* Check if any records were retrieved */
IF RowCount(@sentEventResult) > 0 THEN
/* Loop through the retrieved SentEvent records */
FOR @recordIndex = 1 TO RowCount(@sentEventResult) DO
SET @sentEventData = Row(@sentEventResult, @recordIndex)
SET @batchID = Field(@sentEventData, "BatchID")
SET @triggeredSendDefinitionID = Field(@sentEventData, "TriggeredSendDefinitionObjectID")
SET @eventDate = Field(@sentEventData, "EventDate")
SET @sendID = Field(@sentEventData, "SendID")
SET @subscriberKey = Field(@sentEventData, "SubscriberKey")
/* Output the SentEvent details */
OutputLine(Concat("Batch ID: ", @batchID))
OutputLine(Concat("Triggered Send Definition ID: ", @triggeredSendDefinitionID))
OutputLine(Concat("Event Date: ", @eventDate))
OutputLine(Concat("Send ID: ", @sendID))
OutputLine(Concat("Subscriber Key: ", @subscriberKey))
OutputLine("-------------")
NEXT @recordIndex
ELSE
/* Output message if no records are found */
OutputLine("No SentEvent records found.")
ENDIF
]%%
Write AMPscript block to retrieve DataExtension
%%[
/* Initialize the RetrieveRequest object to fetch DataExtension details by Name */
SET @dataExtensionRequest = CreateObject("RetrieveRequest")
SetObjectProperty(@dataExtensionRequest, "ObjectType", "DataExtension")
AddObjectArrayItem(@dataExtensionRequest, "Properties", "CategoryID")
AddObjectArrayItem(@dataExtensionRequest, "Properties", "CustomerKey")
AddObjectArrayItem(@dataExtensionRequest, "Properties", "CreatedDate")
AddObjectArrayItem(@dataExtensionRequest, "Properties", "Status")
AddObjectArrayItem(@dataExtensionRequest, "Properties", "IsSendable")
AddObjectArrayItem(@dataExtensionRequest, "Properties", "IsTestable")
/* Set up and configure the filter to locate the DataExtension using Name */
SET @dataExtensionNameFilter = CreateObject("SimpleFilterPart")
SetObjectProperty(@dataExtensionNameFilter, "Property", "Name")
SetObjectProperty(@dataExtensionNameFilter, "SimpleOperator", "equals")
AddObjectArrayItem(@dataExtensionNameFilter, "Value", "WebinarConfirmation") /* Replace with the target DataExtension Name */
SetObjectProperty(@dataExtensionRequest, "Filter", @dataExtensionNameFilter)
/* Execute the RetrieveRequest to fetch DataExtension details */
SET @dataExtensionResult = InvokeRetrieve(@dataExtensionRequest, @retrieveStatus, @retrieveRequestID)
/* Output the retrieve status */
OutputLine(Concat("Retrieve Status: ", @retrieveStatus))
/* Check if any records were retrieved */
IF RowCount(@dataExtensionResult) > 0 THEN
/* Loop through the retrieved DataExtension records */
FOR @recordIndex = 1 TO RowCount(@dataExtensionResult) DO
SET @dataExtensionData = Row(@dataExtensionResult, @recordIndex)
SET @categoryID = Field(@dataExtensionData, "CategoryID")
SET @customerKey = Field(@dataExtensionData, "CustomerKey")
SET @createdDate = Field(@dataExtensionData, "CreatedDate")
SET @status = Field(@dataExtensionData, "Status")
SET @isSendable = Field(@dataExtensionData, "IsSendable")
SET @isTestable = Field(@dataExtensionData, "IsTestable")
/* Output the DataExtension details */
OutputLine(Concat("Category ID: ", @categoryID))
OutputLine(Concat("Customer Key: ", @customerKey))
OutputLine(Concat("Created Date: ", @createdDate))
OutputLine(Concat("Status: ", @status))
OutputLine(Concat("Is Sendable: ", @isSendable))
OutputLine(Concat("Is Testable: ", @isTestable))
OutputLine("-------------")
NEXT @recordIndex
ELSE
/* Output message if no records are found */
OutputLine("No DataExtension records found for the specified Name.")
ENDIF
]%%
Write AMPscript block to retrieve ListSubscribers
%%[
/* Initialize the RetrieveRequest object to fetch ListSubscriber details */
SET @listSubscriberRequest = CreateObject("RetrieveRequest")
SetObjectProperty(@listSubscriberRequest, "ObjectType", "ListSubscriber")
AddObjectArrayItem(@listSubscriberRequest, "Properties", "ListID")
AddObjectArrayItem(@listSubscriberRequest, "Properties", "CreatedDate")
AddObjectArrayItem(@listSubscriberRequest, "Properties", "Status")
AddObjectArrayItem(@listSubscriberRequest, "Properties", "SubscriberKey")
AddObjectArrayItem(@listSubscriberRequest, "Properties", "ObjectID")
/* Execute the RetrieveRequest to fetch ListSubscriber details */
SET @listSubscriberResult = InvokeRetrieve(@listSubscriberRequest, @retrieveStatus, @retrieveRequestID)
/* Output the retrieve status */
OutputLine(Concat("Retrieve Status: ", @retrieveStatus))
/* Check if any records were retrieved */
IF RowCount(@listSubscriberResult) > 0 THEN
/* Loop through the retrieved ListSubscriber records */
FOR @recordIndex = 1 TO RowCount(@listSubscriberResult) DO
SET @listSubscriberData = Row(@listSubscriberResult, @recordIndex)
SET @listID = Field(@listSubscriberData, "ListID")
SET @createdDate = Field(@listSubscriberData, "CreatedDate")
SET @status = Field(@listSubscriberData, "Status")
SET @subscriberKey = Field(@listSubscriberData, "SubscriberKey")
SET @objectID = Field(@listSubscriberData, "ObjectID")
/* Output the ListSubscriber details */
OutputLine(Concat("List ID: ", @listID))
OutputLine(Concat("Created Date: ", @createdDate))
OutputLine(Concat("Status: ", @status))
OutputLine(Concat("Subscriber Key: ", @subscriberKey))
OutputLine(Concat("Object ID: ", @objectID))
OutputLine("-------------")
NEXT @recordIndex
ELSE
/* Output message if no records are found */
OutputLine("No ListSubscriber records found.")
ENDIF
]%%
Write AMPscript block to retrieve NotSentEvent
%%[
/* Initialize the RetrieveRequest object to fetch NotSentEvent details */
SET @notSentEventRequest = CreateObject("RetrieveRequest")
SetObjectProperty(@notSentEventRequest, "ObjectType", "NotSentEvent")
AddObjectArrayItem(@notSentEventRequest, "Properties", "BatchID")
AddObjectArrayItem(@notSentEventRequest, "Properties", "TriggeredSendDefinitionObjectID")
AddObjectArrayItem(@notSentEventRequest, "Properties", "EventDate")
AddObjectArrayItem(@notSentEventRequest, "Properties", "SendID")
AddObjectArrayItem(@notSentEventRequest, "Properties", "SubscriberKey")
/* Execute the RetrieveRequest to fetch NotSentEvent details */
SET @notSentEventResult = InvokeRetrieve(@notSentEventRequest, @retrieveStatus, @retrieveRequestID)
/* Output the retrieve status */
OutputLine(Concat("Retrieve Status: ", @retrieveStatus))
/* Check if any records were retrieved */
IF RowCount(@notSentEventResult) > 0 THEN
/* Loop through the retrieved NotSentEvent records */
FOR @recordIndex = 1 TO RowCount(@notSentEventResult) DO
SET @notSentEventData = Row(@notSentEventResult, @recordIndex)
SET @batchID = Field(@notSentEventData, "BatchID")
SET @triggeredSendDefinitionID = Field(@notSentEventData, "TriggeredSendDefinitionObjectID")
SET @eventDate = Field(@notSentEventData, "EventDate")
SET @sendID = Field(@notSentEventData, "SendID")
SET @subscriberKey = Field(@notSentEventData, "SubscriberKey")
/* Output the NotSentEvent details */
OutputLine(Concat("Batch ID: ", @batchID))
OutputLine(Concat("Triggered Send Definition ID: ", @triggeredSendDefinitionID))
OutputLine(Concat("Event Date: ", @eventDate))
OutputLine(Concat("Send ID: ", @sendID))
OutputLine(Concat("Subscriber Key: ", @subscriberKey))
OutputLine("-------------")
NEXT @recordIndex
ELSE
/* Output message if no records are found */
OutputLine("No NotSentEvent records found.")
ENDIF
]%%
Write AMPscript block to retrieve OpenEvent
%%[
/* Initialize the RetrieveRequest object to fetch OpenEvent details */
SET @openEventRequest = CreateObject("RetrieveRequest")
SetObjectProperty(@openEventRequest, "ObjectType", "OpenEvent")
AddObjectArrayItem(@openEventRequest, "Properties", "BatchID")
AddObjectArrayItem(@openEventRequest, "Properties", "TriggeredSendDefinitionObjectID")
AddObjectArrayItem(@openEventRequest, "Properties", "EventDate")
AddObjectArrayItem(@openEventRequest, "Properties", "SendID")
AddObjectArrayItem(@openEventRequest, "Properties", "SubscriberKey")
/* Execute the RetrieveRequest to fetch OpenEvent details */
SET @openEventResult = InvokeRetrieve(@openEventRequest, @retrieveStatus, @retrieveRequestID)
/* Output the retrieve status */
OutputLine(Concat("Retrieve Status: ", @retrieveStatus))
/* Check if any records were retrieved */
IF RowCount(@openEventResult) > 0 THEN
/* Loop through the retrieved OpenEvent records */
FOR @recordIndex = 1 TO RowCount(@openEventResult) DO
SET @openEventData = Row(@openEventResult, @recordIndex)
SET @batchID = Field(@openEventData, "BatchID")
SET @triggeredSendDefinitionID = Field(@openEventData, "TriggeredSendDefinitionObjectID")
SET @eventDate = Field(@openEventData, "EventDate")
SET @sendID = Field(@openEventData, "SendID")
SET @subscriberKey = Field(@openEventData, "SubscriberKey")
/* Output the OpenEvent details */
OutputLine(Concat("Batch ID: ", @batchID))
OutputLine(Concat("Triggered Send Definition ID: ", @triggeredSendDefinitionID))
OutputLine(Concat("Event Date: ", @eventDate))
OutputLine(Concat("Send ID: ", @sendID))
OutputLine(Concat("Subscriber Key: ", @subscriberKey))
OutputLine("-------------")
NEXT @recordIndex
ELSE
/* Output message if no records are found */
OutputLine("No OpenEvent records found.")
ENDIF
]%%
Write AMPscript block to retrieve QueryDefinition
%%[
/* Initialize the RetrieveRequest object to fetch QueryDefinition details */
SET @queryRequest = CreateObject("RetrieveRequest")
SetObjectProperty(@queryRequest, "ObjectType", "QueryDefinition")
AddObjectArrayItem(@queryRequest, "Properties", "CategoryID")
AddObjectArrayItem(@queryRequest, "Properties", "CustomerKey")
AddObjectArrayItem(@queryRequest, "Properties", "CreatedDate")
AddObjectArrayItem(@queryRequest, "Properties", "Status")
AddObjectArrayItem(@queryRequest, "Properties", "QueryText")
AddObjectArrayItem(@queryRequest, "Properties", "Name")
AddObjectArrayItem(@queryRequest, "Properties", "TargetType")
AddObjectArrayItem(@queryRequest, "Properties", "TargetUpdateType")
/* Set up and configure the filter to locate the QueryDefinition using TargetUpdateType */
SET @queryFilter = CreateObject("SimpleFilterPart")
SetObjectProperty(@queryFilter, "Property", "TargetUpdateType") /* Filtering by TargetUpdateType */
SetObjectProperty(@queryFilter, "SimpleOperator", "equals")
AddObjectArrayItem(@queryFilter, "Value", "Overwrite") /* Replace with the actual TargetUpdateType filter value */
SetObjectProperty(@queryRequest, "Filter", @queryFilter)
/* Execute the RetrieveRequest to fetch QueryDefinition details */
SET @queryResult = InvokeRetrieve(@queryRequest, @retrieveStatus, @retrieveRequestID)
/* Output the retrieve status */
OutputLine(Concat("Retrieve Status: ", @retrieveStatus))
/* Check if any records were retrieved */
IF RowCount(@queryResult) > 0 THEN
/* Loop through the retrieved QueryDefinition records */
FOR @recordIndex = 1 TO RowCount(@queryResult) DO
SET @queryData = Row(@queryResult, @recordIndex)
SET @categoryID = Field(@queryData, "CategoryID")
SET @customerKey = Field(@queryData, "CustomerKey")
SET @createdDate = Field(@queryData, "CreatedDate")
SET @status = Field(@queryData, "Status")
SET @queryText = Field(@queryData, "QueryText")
SET @name = Field(@queryData, "Name")
SET @targetType = Field(@queryData, "TargetType")
SET @targetUpdateType = Field(@queryData, "TargetUpdateType")
/* Output the QueryDefinition details */
OutputLine(Concat("Category ID: ", @categoryID))
OutputLine(Concat("CustomerKey: ", @customerKey))
OutputLine(Concat("Created Date: ", @createdDate))
OutputLine(Concat("Status: ", @status))
OutputLine(Concat("Query Text: ", @queryText))
OutputLine(Concat("Name: ", @name))
OutputLine(Concat("Target Type: ", @targetType))
OutputLine(Concat("Target Update Type: ", @targetUpdateType))
OutputLine("-------------")
NEXT @recordIndex
ELSE
/* Output message if no records are found */
OutputLine("No QueryDefinition records found with the specified filter.")
ENDIF
]%%
Write AMPscript block to retrieve SendSummary
%%[
/* Initialize the RetrieveRequest object to fetch SendSummary details */
SET @sendSummaryRequest = CreateObject("RetrieveRequest")
SetObjectProperty(@sendSummaryRequest, "ObjectType", "SendSummary")
AddObjectArrayItem(@sendSummaryRequest, "Properties", "AccountID")
AddObjectArrayItem(@sendSummaryRequest, "Properties", "AccountName")
AddObjectArrayItem(@sendSummaryRequest, "Properties", "CreatedDate")
AddObjectArrayItem(@sendSummaryRequest, "Properties", "SendID")
AddObjectArrayItem(@sendSummaryRequest, "Properties", "TotalSent")
AddObjectArrayItem(@sendSummaryRequest, "Properties", "Transactional")
AddObjectArrayItem(@sendSummaryRequest, "Properties", "NonTransactional")
AddObjectArrayItem(@sendSummaryRequest, "Properties", "DeliveredTime")
/* Execute the RetrieveRequest to fetch SendSummary details */
SET @sendSummaryResult = InvokeRetrieve(@sendSummaryRequest, @retrieveStatus, @retrieveRequestID)
/* Output the retrieve status */
OutputLine(Concat("Retrieve Status: ", @retrieveStatus))
/* Check if any records were retrieved */
IF RowCount(@sendSummaryResult) > 0 THEN
/* Loop through the retrieved SendSummary records */
FOR @recordIndex = 1 TO RowCount(@sendSummaryResult) DO
SET @sendSummaryData = Row(@sendSummaryResult, @recordIndex)
SET @accountID = Field(@sendSummaryData, "AccountID")
SET @accountName = Field(@sendSummaryData, "AccountName")
SET @createdDate = Field(@sendSummaryData, "CreatedDate")
SET @sendID = Field(@sendSummaryData, "SendID")
SET @totalSent = Field(@sendSummaryData, "TotalSent")
SET @transactional = Field(@sendSummaryData, "Transactional")
SET @nonTransactional = Field(@sendSummaryData, "NonTransactional")
SET @deliveredTime = Field(@sendSummaryData, "DeliveredTime")
/* Output the SendSummary details */
OutputLine(Concat("Account ID: ", @accountID))
OutputLine(Concat("Account Name: ", @accountName))
OutputLine(Concat("Created Date: ", @createdDate))
OutputLine(Concat("Send ID: ", @sendID))
OutputLine(Concat("Total Sent: ", @totalSent))
OutputLine(Concat("Transactional: ", @transactional))
OutputLine(Concat("Non-Transactional: ", @nonTransactional))
OutputLine(Concat("Delivered Time: ", @deliveredTime))
OutputLine("-------------")
NEXT @recordIndex
ELSE
/* Output message if no records are found */
OutputLine("No SendSummary records found.")
ENDIF
]%%
Write AMPscript block to retrieve Subscribers
%%[
/* Specify the MID (Client ID) */
SET @clientID = "123456789"
/* Create RetrieveRequest object for Subscriber */
SET @subscriberRetrieveRequest = CreateObject("RetrieveRequest")
SetObjectProperty(@subscriberRetrieveRequest, "ObjectType", "Subscriber")
/* Specify properties to retrieve */
AddObjectArrayItem(@subscriberRetrieveRequest, "Properties", "SubscriberKey")
AddObjectArrayItem(@subscriberRetrieveRequest, "Properties", "EmailAddress")
AddObjectArrayItem(@subscriberRetrieveRequest, "Properties", "Status")
AddObjectArrayItem(@subscriberRetrieveRequest, "Properties", "CreatedDate")
AddObjectArrayItem(@subscriberRetrieveRequest, "Properties", "Client.ID") /* MID filter */
/* Create and apply filter for Client.ID */
SET @clientIDFilter = CreateObject("SimpleFilterPart")
SetObjectProperty(@clientIDFilter, "Property", "Client.ID")
SetObjectProperty(@clientIDFilter, "SimpleOperator", "equals")
AddObjectArrayItem(@clientIDFilter, "Value", @clientID)
/* Assign the filter to the RetrieveRequest */
SetObjectProperty(@subscriberRetrieveRequest, "Filter", @clientIDFilter)
/* Perform the retrieve operation */
SET @subscriberResponse = InvokeRetrieve(@subscriberRetrieveRequest, @retrieveStatus, @retrieveRequestID)
/* Output retrieved results if found */
IF RowCount(@subscriberResponse) > 0 THEN
FOR @rowIndex = 1 TO RowCount(@subscriberResponse) DO
SET @subscriberRow = Row(@subscriberResponse, @rowIndex)
SET @retrievedSubscriberKey = Field(@subscriberRow, "SubscriberKey")
SET @retrievedEmail = Field(@subscriberRow, "EmailAddress")
SET @retrievedStatus = Field(@subscriberRow, "Status")
SET @retrievedDate = Field(@subscriberRow, "CreatedDate")
/* Output subscriber details */
OutputLine(Concat("SubscriberKey: ", @retrievedSubscriberKey))
OutputLine(Concat("EmailAddress: ", @retrievedEmail))
OutputLine(Concat("Status: ", @retrievedStatus))
OutputLine(Concat("CreatedDate: ", @retrievedDate))
NEXT @rowIndex
ELSE
OutputLine("No subscribers found for the specified Client ID.")
ENDIF
]%%
Write AMPscript block to retrieve Triggered Send Summary
%%[
/* Initialize the RetrieveRequest object to fetch SendSummary details */
SET @sendSummaryRequest = CreateObject("RetrieveRequest")
SetObjectProperty(@sendSummaryRequest, "ObjectType", "TriggeredSendSummary")
AddObjectArrayItem(@sendSummaryRequest, "Properties", "Bounces")
AddObjectArrayItem(@sendSummaryRequest, "Properties", "Clicks")
AddObjectArrayItem(@sendSummaryRequest, "Properties", "NotSentDueToError")
AddObjectArrayItem(@sendSummaryRequest, "Properties", "NotSentDueToOptOut")
AddObjectArrayItem(@sendSummaryRequest, "Properties", "Opens")
AddObjectArrayItem(@sendSummaryRequest, "Properties", "OptOuts")
AddObjectArrayItem(@sendSummaryRequest, "Properties", "Sent")
AddObjectArrayItem(@sendSummaryRequest, "Properties", "UniqueClicks")
AddObjectArrayItem(@sendSummaryRequest, "Properties", "UniqueOpens")
/* Execute the RetrieveRequest to fetch SendSummary details */
SET @sendSummaryResult = InvokeRetrieve(@sendSummaryRequest, @retrieveStatus, @retrieveRequestID)
/* Output the retrieve status */
OutputLine(Concat("Retrieve Status: ", @retrieveStatus))
/* Check if any records were retrieved */
IF RowCount(@sendSummaryResult) > 0 THEN
/* Loop through the retrieved SendSummary records */
FOR @recordIndex = 1 TO RowCount(@sendSummaryResult) DO
SET @sendSummaryData = Row(@sendSummaryResult, @recordIndex)
SET @accountID = Field(@sendSummaryData, "AccountID")
SET @accountName = Field(@sendSummaryData, "AccountName")
SET @createdDate = Field(@sendSummaryData, "CreatedDate")
SET @sendID = Field(@sendSummaryData, "SendID")
SET @totalSent = Field(@sendSummaryData, "TotalSent")
SET @transactional = Field(@sendSummaryData, "Transactional")
SET @nonTransactional = Field(@sendSummaryData, "NonTransactional")
SET @deliveredTime = Field(@sendSummaryData, "DeliveredTime")
/* Output the SendSummary details */
OutputLine(Concat("Account ID: ", @accountID))
OutputLine(Concat("Account Name: ", @accountName))
OutputLine(Concat("Created Date: ", @createdDate))
OutputLine(Concat("Send ID: ", @sendID))
OutputLine(Concat("Total Sent: ", @totalSent))
OutputLine(Concat("Transactional: ", @transactional))
OutputLine(Concat("Non-Transactional: ", @nonTransactional))
OutputLine(Concat("Delivered Time: ", @deliveredTime))
OutputLine("-------------")
NEXT @recordIndex
ELSE
/* Output message if no records are found */
OutputLine("No SendSummary records found.")
ENDIF
]%%
Write AMPscript block to retrieve UnsubEvent
%%[
/* Initialize the RetrieveRequest object to fetch UnsubEvent details */
SET @unsubEventRequest = CreateObject("RetrieveRequest")
SetObjectProperty(@unsubEventRequest, "ObjectType", "UnsubEvent")
AddObjectArrayItem(@unsubEventRequest, "Properties", "BatchID")
AddObjectArrayItem(@unsubEventRequest, "Properties", "EventDate")
AddObjectArrayItem(@unsubEventRequest, "Properties", "SendID")
AddObjectArrayItem(@unsubEventRequest, "Properties", "SubscriberKey")
/* Execute the RetrieveRequest to fetch UnsubEvent details */
SET @unsubEventResult = InvokeRetrieve(@unsubEventRequest, @retrieveStatus, @retrieveRequestID)
/* Output the retrieve status */
OutputLine(Concat("Retrieve Status: ", @retrieveStatus))
/* Check if any records were retrieved */
IF RowCount(@unsubEventResult) > 0 THEN
/* Loop through the retrieved UnsubEvent records */
FOR @recordIndex = 1 TO RowCount(@unsubEventResult) DO
SET @unsubEventData = Row(@unsubEventResult, @recordIndex)
SET @batchID = Field(@unsubEventData, "BatchID")
SET @eventDate = Field(@unsubEventData, "EventDate")
SET @sendID = Field(@unsubEventData, "SendID")
SET @subscriberKey = Field(@unsubEventData, "SubscriberKey")
/* Output the UnsubEvent details */
OutputLine(Concat("Batch ID: ", @batchID))
OutputLine(Concat("Event Date: ", @eventDate))
OutputLine(Concat("Send ID: ", @sendID))
OutputLine(Concat("Subscriber Key: ", @subscriberKey))
OutputLine("-------------")
NEXT @recordIndex
ELSE
/* Output message if no records are found */
OutputLine("No UnsubEvent records found.")
ENDIF
]%%
Comments
Post a Comment