Passing Results from Ruby Script Back to Campaign Workflow | Community
Skip to main content
davidh2892249
Level 5
August 8, 2024
Question

Passing Results from Ruby Script Back to Campaign Workflow

  • August 8, 2024
  • 2 replies
  • 1327 views

Hi All,

 

Working on a project where we are using a Ruby script in a multiscript activity. Following it's completion, we'd like to be able to pass results back to the workflow to use downstream. e.g. populate variables like instance.vars.xxxxx 

 

Can anyone expand pass results back to a workflow from a multiscript activity? (whether it be python/ruby/shell etc)

 

Thanks

 

David

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

davidh2892249
Level 5
August 8, 2024

Clearly I meant to say in final sentence:

Can anyone expand on how to pass results back to a workflow from a multiscript activity? (whether it be python/ruby/shell etc)

Manoj_Kumar
Community Advisor
Community Advisor
August 13, 2024

Hello @davidh2892249  You can create a file with your script, write data in the file and then use data loading activity to read the file on server.

Manoj  | https://themartech.pro
davidh2892249
Level 5
August 13, 2024

Hi Manoj

 

Thanks for your reply.

I guess my question there would be how do you pass the name of the file back to the workflow as vars.filename so that the dataloading activity knows which file to pick up?

We've come up with a solution where we "calculate" a name, but ideally we'd like to pass explicit outputs of the script back to the workflow.

 

Any thoughts would be appreciated.

 

Thanks

 

David

MeitMedia
Level 4
August 27, 2024

Hi @davidh2892249 ,

 

To handle explicit outputs from external scripts like Ruby in ACC, you can try these two approaches:

Option 1: Handling Files Directly

  • Generate Output in the External Script: Run your Ruby script externally to create both the main output file (e.g., output_data.csv) and a metadata file containing the filename or path. Example Ruby Code:
File.open('output_data.csv', 'w') { |file| file.write("Header1,Header2\nData1,Data2") } File.open('metadata.txt', 'w') { |file| file.write("output_data.csv") }​
  • Store Files in an Accessible Location: Save both files in a directory accessible by Adobe Campaign Classic.
  • Use File Loading Activity: Configure a File Loading activity in Adobe Campaign Classic to load the metadata file. Manually configure the expected filename based on the metadata file contents in subsequent activities.
  • Process the Data File: With the filename or path available, use it in downstream activities like Data Loading or File Upload activities.

Option 2: Integrating with External Services (via ACC)

If the logic is complex and needs Ruby or another language, execute it externally (e.g., on a server) and then capture the results.

  • Create an External Service: Host your Ruby script on an external server. This service should expose an API endpoint that Adobe Campaign can call.
  • Make HTTP Requests from Adobe Campaign: In your AC workflow use HttpClientRequest function or any other HTTP functions to configure and send the request. 
    Example:
// Define the API endpoint URL var url = "https://your-external-service.com/api"; // Create an instance of HttpClientRequest var request = new HttpClientRequest(url); // Optionally, set the HTTP method and headers if needed request.method = "GET"; // HTTP method (GET, POST, etc.) request.headers["Content-Type"] = "application/json"; // Set headers using bracket notation // Execute the request var response = request.execute(); // Capture the result from the response var result = response.content; // Set the result to a workflow variable instance.vars.myVariable = result;​
  • Process Results in the Workflow: Once you have set the workflow variable (myVariable), you can use it in downstream activities as needed.

Choose the approach that aligns best with your workflow requirements and the capabilities of ACC.

 

Best regards,

MEIT MEDIA (https://www.meitmedia.com)

Find us on LinkedIn

Contact Us: infomeitmedia@gmail.com