0

I'm looking for a way to export a Data Extension using SSJS.

I know it's possible to create a script activity using SSJS and then executing that. Is it possible to do the same with an export activity? Is it possible to do it directly just using SSJS?

If not, are there any alternatives that allow me to programmatically export a Data Extension to an FTP server?

Thanks!

1 Answer 1

1

The only way to interact with the SFTP is Data Extract/File Transfer (and imports).

The problem is that you need both, one after the other is finished.

-> The solution is to put them into an automation, and start that. That takes care of the sequence.

-> The limit to a full programmatic solution is that you cannot create the DataExtractActivity via API, according to docs: https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/supported_operations_for_objects_and_methods.html

(You could create the file transfer, the automation, etc.)

Depending on your usecase you can get around that. Just build one fixed extract by hand, and programmatically change what you put into the DE it extracts.

You can "run once" the automation with SSJS / WSProxy.

For that: Put your required processing into an automation with an empty schedule (which gives it the desired "Ready" state to be run once via API, also known as automation status "2").

Get the objectId (if you use the API to get it, ProgramID) of the automation.

Then write ssjs script that starts / performs / runs once that automation: https://www.ssjsdocs.xyz/automation-studio/automations/startstop.html

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

var objectID = "S0M3-GU1D-K3Y-G03SR1G4T-H3R3";

var props = {
    ObjectID: objectID
};

var action = ["start", "stop"];

var opts = {};

var result = api.performItem("Automation", props, action[1], opts);
1
  • Thanks! This should do what I need. Commented Jul 17, 2024 at 19:17

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.