cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
517
Views
0
Helpful
3
Replies

How to get variable from script in CPO.

esramasa
Cisco Employee
Cisco Employee

HI,

I am storing a output in a variable inside a script.

 

I want to access the output variable in the process.

 

How to use the variable defined inside the script in CPO.

1 Accepted Solution

Accepted Solutions

Svetlana Kryukova
Participant
Participant

I assume you are talking about either PowerShell script (Execute Windows PowerShell Scrtipt activity) or a VBScript  (Execute Windows Script activity). In both cases, the only way to pass the data out is to send it to standard output and then to refer to the "Output" property of the activity in the subsequent activities where you need to use it.

If needed you can define a variable (a global variable, or a process output/local variable or a target property) and save the Output property of the script activity into that variable using Set Variable activity.

View solution in original post

3 Replies 3

Svetlana Kryukova
Participant
Participant

I assume you are talking about either PowerShell script (Execute Windows PowerShell Scrtipt activity) or a VBScript  (Execute Windows Script activity). In both cases, the only way to pass the data out is to send it to standard output and then to refer to the "Output" property of the activity in the subsequent activities where you need to use it.

If needed you can define a variable (a global variable, or a process output/local variable or a target property) and save the Output property of the script activity into that variable using Set Variable activity.

Thank you so much for your reply.

 

Can you please tell me how to extract only the needed part from the standard output to a variable.

The answer is "it depends".

If you can limit the output of your script to JUST the value you are interested in, then there is no need for any kind of parsing. You can simply refer to the "Workflow.ScriptActivity.Output" property and use it as is.

If your script produces lots of output, the parsing will depend on the output produced, wouldn't it?

You could also write the variable you are interested in a "file", and then simply read the file in a different activity.

If you have control over the script then you should consider the fact that it is much easier to parse "structured" text, such as XML, JSON, HTML, or CSV output. So, you could consider refactoring your script to produce "structured" output and then using one of the builtin Orchestrator activities (such as XPath Query, XSL Transform, JSON to XML or Read Table) to parse the Output property of the Windows Script activity into the appropriate format.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: