Solved

Workflow: Create PopupInput with Java?

  • 25 August 2023
  • 6 replies
  • 85 views

Userlevel 1
Badge +5

Hi community.

 

I would like to know how I can dynamically create a PopupInput with java code. Example use case: At first I fill a variable (list) with values (e.g. from a db query). Let’s assume the value of this variable is: Value1, Value2, Value3. Now I need to ask the for information for each single value with a PopupInput like in the screenshot below.

 

 

 

I would guess that I need to start like this:

import commvault.cte.workflow.dom.WorkflowElement;

WorkflowElement PopupInput = WorkflowElement.parse(...

 

But honestly I have no idea how to continue from here on.

 

Best regards

Pasqual

icon

Best answer by Yeshwanth 1 September 2023, 10:56

View original

6 replies

Userlevel 1
Badge +4

Hi @Pasqual Döhring ,

Can you try something like this?

 

import commvault.msgs.App.XMLSchema;
import commvault.msgs.App.InputControlType;
variableInputs = xpath:{/workflow/variables/popupInputs};
int serial = 1;
for(int i=0; i < variableInputs.size(); i++){
        XMLSchema input = new XMLSchema();
        displayName = variableInputs.get(i);
        name = "INPUT" + Integer.toString(serial);
        input.setInputName(name);
        input.setHidden(false);
        input.setControlType(InputControlType.TEXTBOX);
        input.setDisplayName(displayName);
        input.setRequired(true);
        activity.getForm().getEntries().add(input);        
        serial++;
    }

 

Thanks,

Yeshwanth

Userlevel 1
Badge +5

Hi Yeshwanth,

 

thank you for the code. In general this looks promising. Unfortunately it fails at the point when it tries to add the “input” to the PopupInput because we never created that. So I still need a possibility to create the PopupInput at all. And of course I need to show it and need a way to catch the results.

 

I get this error message when executing this code “activity.getForm().getEntries().add(input);”:

 

Thank you.

Pasqual

Userlevel 1
Badge +4

Hi Pasqual,

 

You need to create a Popupinput activity by dragging and dropping it. Then you can add this code in onStartScript of that activity. 

 

Thanks,

Yeshwanth

Userlevel 1
Badge +5

I have found the answer myself. Have a look into this post:

 

 

Userlevel 1
Badge +5

Hi @Yeshwanth.

 

I need help with this again. I already created a new topic on this but got now answer for 26 days.

 

I know this is going to be a double post but anyway I am going to copy&paste it here:

 

I have a workflow in which I am creating a dynamic PopupInput. Here is some pseudo code similar to that what I am using:

import commvault.msgs.App.XMLSchema;
import commvault.msgs.App.InputControlType;

XMLSchema input = new XMLSchema();
input.setDefaultValue("Default"); 
input.setInputName("INPUT1");
input.setHidden(false);
input.setListType(false);
input.setControlType(InputControlType.TEXTBOX);
input.setDisplayName("Display Name");
input.setRequired(false);
activity.getForm().getEntries().add(input);

This works well so far. But I am struggling to get the output of the PopupInput because the entry “INPUT1” seems to not exist. I tried a few things within a “Script” activity or even in the OnComplete Script of the PopupInput. For example I iterated through “activity.getForm().getEntries()” but the entry “INPUT1” did not exist. But nothing has been working.

Does anybody know how to get the value of my entry? (Remember: That is just pseudo code. In reality I am generating  many input fields completely dynamically and cannot generate a static PopupInput.)

Userlevel 1
Badge +5

Hi Yeshwanth.

 

Sorry for the delayed answer but I was a little busy.

You solution works very well. Thanks alot.

 

Pasqual

Reply