Support > Forums > OpenBots Studio > Can you run Commands in the "Evaluate Snippet"

Can you run Commands in the "Evaluate Snippet"

Leonardo Avalos

  • Reporter
  • Calender Icon July 20,2021 at 4:59 PM

I want to change the way my workflow goes by running it as a script in the Evaluate Snippet Command. I'm trying to run the "Run Task" command, but I see that in order to call the method Task RunCommand(object sender), it takes an instance of IAutomationEngineInstance. I tried creating this object, but when the workflow runs, nothing happens, so I'm guessing that whatever that object is, it needs to come from the project itself. How do I get the currently running IAutomationEngineInstance to call the RunCommand method in the SeleniumNavigateToURLCommand class? Or am I looking at this the wrong way? Any help is greatly appreciated. Thanks.

This forum has 314 topics, 681 replies, and was last updated 8 days ago by Support Agent

Nataly Alvarado...

  • Participant
  • Calender Icon July 30,2021 at 2:44 PM

Leonardo,

Thanks for clarifying the scenario. Users do not have access to the engine object, calling a child script from the Evaluate Snippet command won't be possible since Run Task is too complex to work without an engine instance.

However, based on the scenario described, the Run Task command can be used to accomplish the wanted task by formatting your script as follows:

If (condition) Run Task 1 Else If Run Task 2 Else Run Task 3

In Studio v1.5.2 and forward, the If Command allows you to write any conditional logic in the If Condition field, as long as the Condition Option is set to "Inline" and the overall statement results in a true or false return value.

Another option, is to use the Evaluate Snippet command to write the condition and set the value to a boolean variable. Then, this boolean can be used as input for the If Command.

Leonardo Avalos

  • Participant
  • Calender Icon July 26,2021 at 6:32 PM

Not quite. What I want to do is figure out how to programmatically call a child script using C#. My idea was to create snippets that have some conditional logic and call the correct child scripts. In other words, I want to be able to call a child script without using the Run Task command, instead calling it directly with code from my Evaluate Snippet task.

Nataly Alvarado...

  • Participant
  • Calender Icon July 26,2021 at 6:26 PM

Hello Leonardo,

from what I understood, you are trying to modularize your project by invoking child scripts from Main. Is this correct? If that is the case, you should use the Run Task command and indicate the file path to the child script. If the child script contains arguments, it will ask for the variable or value to pass in, out or in/out of the child script.

Let me know is this answers your question, or please provide more information so we can better assist you.

Thanks!

You are not authorized to reply, please click here to login and add your reply to this topic.