Skip to main content

Here’s an annoyingly wierd one.

 

I have a workflow that does parsing to create a string for use in a powershell script.

 

This is what the script looks like:

//Prep Hardcoded Values for use in Powershell
def vCentersList = xpath:{/workflow/configuration/vCenters};
def vCenterCount = vCentersList.size();
def BackupPolicies = xpath:{/workflow/configuration/BackupPolicies};
def forCounter = 0;


// Convert vCenter List to vCenter String
StringBuilder strbul = new StringBuilder();
strbul.append("@(");

for(String str : vCentersList)
{
forCounter++;
strbul.append("'");
strbul.append(str.replaceAll("\\s",""));
strbul.append("'");
if (forCounter != vCenterCount){strbul.append(";");}
}

strbul.append(")");
String vCenters = strbul.toString();
workflow.setVariable("vCenters",vCenters);

return vCenters;

 

The input is a list of vCenter cliententities.. which looks something like this:

/“vCenter1”, “vCenter2”, “vCenter3”]

 

When I run the script in the debugger the script returns the following:

@('vCenter1';'vCenter2';'vCenter3')

When I run execute the script this is what the workflowengine.log shows:

@()

LOL, 

 

BRUH

 

My guess is that your vCentersList is actually empty when running it outside the debugger.

You are populating it from a configuration property ‘xpath:{/workflow/configuration/vCenters}’.

The debugger reads the configuration property values from the defaults set in the workflow schema itself. But when you execute normally (outside the debugger) the workflow engine reads the values stored for the workflow configuration properties from the CommServe database.

I suggest try refreshing the list of workflows in the console then go to the Properties>Configuration tab of the workflow. Set the vCenters list property there then give it another run. 

If that doesn’t sort it then to troubleshoot further you can add a line logger.debug(vCentersList); to output the current value to the workflowEngine.log when it runs and see if it has picked up what you expect etc.


Thats an excellent point. I hardcoded the options in the xml because the dropdown box to select the clients is atrocious. 


so the question is if I resubmitted the workflow definition would it update the DB with the configuration options in the xml or do I have to do it via the gui?


My understanding is that...

Once you set a value in the DB (eg via setting the property in the workfows section in the console) then that value takes precedence from then on.  

If the value has never been saved in the DB and you simply set/change the value in the definition and deploy the workflow again then the console shows the current value that is in the definition.

 


This makes sense.

 

i have run into this a number of times where the debugger and running script didnt match, now I know why. 

Ill play around with this and get back to you.


@RMcG ,

Worked like a charm.

 

 


Reply