Expand my Community achievements bar.

Join us for the Adobe Campaign Community Q&A Coffee Break on 30th September at 8 am PT with Campaign experts Arthur Lacroix and Sandra Hausmann.

Passing Results from Ruby Script Back to Campaign Workflow

Avatar

Level 5

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

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

6 Replies

Avatar

Level 5

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)

Avatar

Community Advisor

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
     Find me on LinkedIn

Avatar

Level 5

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

Avatar

Community Advisor

Hello @davidh2892249  You can use the dynamic file name in the file upload activity and select calculated option.

 

 


     Manoj
     Find me on LinkedIn

Avatar

Level 5

Hi Manoj

Thanks, I think you are suggesting using a calculated name that matches what we ASSUME will be the filename generated by the ruby script.

We can do that by giving the ruby script variables FROM the workflow and generate a filename based on a pattern, and then make the calculated name in the file upload activity match that pattern.....

 

We have a solution working like that, but what I'm looking to better understand is how can you pass an output from a ruby script back from a workflow - so that the workflow can process explicit (rather than assumed) info from the ruby script.

 

I hope this makes sense.

 

Thanks

 

David

Avatar

Level 5

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

MeitMedia_0-1724786897778.png