Local variable values passed between process and subprocess?

I just started designing a process where I’ve got several script tasks that will need to be used over and over again through out. My initial thought was to put those script tasks in a subprocess and just call that anytime I need the scripts. This would greatly simplify script maintenance. The scripts primarily manipulate a group of local variables.

In debugging, though, local variable values do not appear to pass between the parent process and subprocess. I’ve got local variables with the same names set up in both the parent and subprocess. When debugging, as soon as it steps into the subprocess all the variable values are emptied out. I’ve looked around for a setting that may affect this (like the “back up job information”) but haven’t found a setting that passes the information. I’ve got 10-15 variable values to pass between parent and sub.

Am I doing something wrong or can this be done? I get that a process and subprocess are separate, but I figured as long as each had identically named local variables, the data in them would be carried through.

I’m using Connect Workflow 2018.2.

Thanks!

It isn’t specifically said in the documentation (couldn’t find that written explicitly) but I found a page where you can find an explanation.

Basically, local variables inside a subprocess aren’t the same as local variable of the calling process, even if they have the same name. You need to use global variable or jobInfo to pass down and up value to/from a subprocess.

Ok, that helps. Since I have so many local variables I may have to use some type of structured file to pass info between parent and subprocess (if I decide to go that way).

You could pass on a JSON string through a jobInfo.

Late to the party, but if anybody is still looking for a solution to this: I had to resolve a similar issue recently, but in my case it was a subprocess using a number of parameters of at least three, with optional ones in order to pass SQL text into a db query task.

I ended up building a pipe-delimited config string and using a JS script task to .Split(“|”) into an array and extract the values that way. Example:
DB|schema|table|-ir|2|-h|-l|-t|-f

Then what followed was:

var configString = Watch.GetJobInfo(9);
var configParameters = configString.split("|");
var dbName = configParameters[0];
var dbSchema = configParameters[1];
var dbStagingTableName = configParameters[2];
(...)
var configParameter = "";
for(var x = 3; x < configParameterCount; x++){
	configParameter = configParameters[x]
	switch(configParameter) {
	case "-h":
		//stuff
		break;
	case "-w":
		//stuff
		break;
	case "-l":
		//stuff
		break;
	case "-f":
		//stuff
		break;
	case "-t":
		//stuff
		break;
	case "-d":
		//stuff
		break;
	case "-ir":
		x++; //parameter needs to be followed by an input value, so increment x by 1
		//stuff
		break;
	default:
		throw('Invalid parameter');
		break;
	}
}

Hope this helps.