Solved

Workflows: Utilizing the workflow activities in a script

  • 21 February 2022
  • 10 replies
  • 367 views

Userlevel 5
Badge +16

I need to access a some information at the beginning of the workflow, specifically I need to do a query on the fly in order to populate some dynamic form fields. 

In order to do this I think there are two options.

 

  1. The first is option is to instantiate the CommserveDBquery class and use the output, I was able to find the class definition but a few things are not clear. The following screenshots will hopefully make it clear. This a is screenshot of the class definition, the assumption being that the fields that needs to be populated are “CommCell” , and sql. 
    This is the code I came up with to do it. 

    You can see that the things I don’t know how to define is “resultset” and “activitycontext”, this makes since typically within the workflow “activity” is contextual so executing an activity that is not connected to the workflow would need to be populated.  

  2. The second option is to have an activity defined with the fields pre-populated. Like this:

    The issue in this instance is I have absolutely no idea how to execute this.

icon

Best answer by Chris Sunderland 23 February 2022, 20:22

View original

If you have a question or comment, please create a topic

10 replies

Userlevel 3
Badge +6

Hi @christopherlecky, please check out the documentation of the CommServDBQuery activity. there are examples on how to use it

CommservDBQuery

 

Userlevel 5
Badge +16

Hi @christopherlecky, please check out the documentation of the CommServDBQuery activity. there are examples on how to use it

CommservDBQuery

 

In the case of inputs being defined in the workflow itself how do I access an activity that has not been executed yet?

I would assume the activity would have to executed prior to getting the results. 

This is why I am asking how to execute the activity.

Userlevel 3
Badge +6

You would need to use interactive workflows, which would allow you to run db query activities and use the results to populate PopupInput activities.  Once you are done with the data collection, then you would need to call EndUserSession before you begin the actual work of the workflow.

I’ve attached a small sample workflow to demonstrate this.

A couple of points:

  • On General tab of the Workflow Properties, you need to set Start interactive session to true
  • In the PopupInput activities, you go to Customize Inputs, and set the possible labels and values to the outputs of the db query activity.
Userlevel 5
Badge +16

Hello Chris, those options are set.

I opened a ticket for the problem that dynamic input rules are not working with user interaction activities. 

The rules do happen to work with the workflow inputs themselves, but that raises this question of being able to do a query *prior to* the workflow form itself loading.

Which is I why I phrased the question the way I did. 

This way I can run a script to execute the query and populate the inputs of the workflow form.

Userlevel 3
Badge +6

Currently workflows do not support executing a query prior to the input form loading.

 

Userlevel 5
Badge +16

Currently workflows do not support executing a query prior to the input form loading.

 

That makes sense but can the activity objects be interacted with purely in code?

 

the reason I ask is because some workflows are becoming gigantic physically just because of the size of the activities. 

Essentially it’s much easier to navigate text that icons.

Userlevel 5
Badge +16

It doesn’t necessarily have to be on loading of the form, in fact if there was a simple was of calling a process block from a script that would be awesome. 

I would take that since it would not require an answer for every activity type.

Userlevel 3
Badge +6

Here is some code that will allow you to execute a process block from script.

Not sure how good restartability will be with this but it will call the process block and pass whatever inputs you provide to it.

import commvault.cte.workflow.activities.ExecuteSuperProcess;
import commvault.cte.workflow.dom.WorkflowElement;

ExecuteSuperProcess esp = new ExecuteSuperProcess();
esp.inputs = WorkflowElement.parse("<inputs><input_1>one</input_1><input_2>two</input_2></inputs>");
esp.processBlock = WorkflowElement.parse("<processBlock>ProcessBlock_1</processBlock>");
esp.execute(workflow);

 

Userlevel 5
Badge +16

Absolute Genius, thank you Chris, I will test and report back.

Userlevel 7
Badge +23

Absolute Genius, thank you Chris, I will test and report back.

@Chris Sunderland is brilliant for sure!!