I'm trying to create an API call that will return the SQL Code from all Query Activities within an given Automation.
Using the information provided in this question Retrieve multiple tasks in an Automation via API, I have been able to develop the following SSJS on a Cloud Page:
var api = new Script.Util.WSProxy();
var cols1 = ['ObjectID'];
var Program = api.retrieve('Program', cols1, { Property : 'CustomerKey', SimpleOperator : 'equals', Value : '##automationCustomerKey##' });
var objectid = Program.Results[0].ObjectID;
var cols2 = ['ObjectID','Name'];
var Activity = api.retrieve('Activity', cols2, { Property : 'Program.ObjectID', SimpleOperator : 'equals', Value : objectid });
Write(Stringify(Activity));
This successfully outputs a list of all the Automation Activities in the specified Automation.
From here I want to identify which of the Activities in the Automation are the "SQL Query" type, and call the "QueryDefinition" API to get the "QueryText" Value (the SQL Code).
However there is no clear way to identify what TYPE of activity each of them are; SQL Query, SSJS Script, Send Email, etc.
The following table corresponds to the "PartnerAPIObjectID" values that match each activity type:
42 User-initiated Email
43 Import Definition
45 Group Definition
53 File Transfer Activity
73 Data Extract Activity
84 Report Activity
300 Query Activity
303 Filter Activity
423 Server Side Javascript Activity
425 ELT Activity
427 Build Audience Activity
467 Program Wait
724 Mobile Automation List Refresh Instance
725 MobileConnect Message Instance
726 Mobile File Import Instance
733 InteractionStudio
736 MobilePush Message Object Instance
749 Interaction Studio Event
756 Interaction Studio Date Event
771 Salesforce Send Activiy
783 GroupConnect
1010 Thunderhead Transfer Activity
1101 Interaction Studio Decision Activity
1701 PredictiveIntelligenceRecommendationActivity
Source: Salesforce Tier 2 Technical Support, Oct 2019
As above (and in the linked question), the "Activity" endpoint does not seem to have any reference to the "Activity Type" or a "PartnerAPIObjectID" field.
I'm looking for any information on how to achieve my goal - getting the SQL code of all activities within a given Automation.