All in one process

I am trying to create an all in one workflow but I am having a hard time figuring out how to make the template and data mapper dynamic. There is an option to use the global variables but I need to change the name slightly by substring.

Is there a way to change the global variable through code and use it on the data mapping configuration (0%)? What is the best way to do this?

The dynamic name doesn’t necessarily have to use the %o variable. You can edit it by double clicking on it. You could use one of the JobInfos instead (%1 - %9) or your own local variable (e.g. %{myVariable} ) or any combination of these.

If you need to fine-tune the contents of the variable, you can use a JS Script right before the All In One task, with code similar to this:

	var myNewVar = Watch.ExpandString("%o");
	myNewVar = myNewVar + "_0001.OL-datamapper";
	Watch.SetVariable("myVariable", myNewVariable);

This code takes the current content of the %o system variable and appends _0001.OL-datamapper to it.

In the DataMapper section of the All In One task, you can then just replace the %o value with %{myVariable}.

Thank you. This will work. Although, is it the best option? Ideally, I would like to create a external file that has the datamapper name, template name based on the folder capture masks. e.g. If file starts with Regular_. assign the data mapper name and template to variables so I can use them in ALL in one process.

File :

Masks|DataMapperName|TemplateName|

Regular | Regularxxxx991|Regularxxxx991|

Use a script to extract the appropriate part of the filename that will tell you which resources to use. Say, for instance, you have filenames that follow a pattern like this:

   Regular_xxxx991
   Special_xx2849
   Unspecified_xxxxx9

Your script could then be something like this:

  var myFileName = Watch.ExpandString("%o");
  var myTokens = myToken.match(/[A-Z]+_/gi);
  var token = "";
  if(myTokens) {
    token = myTokens[0];
  }
  Watch.SetVariable("myVariable", token);

This will store either Regular, Special or Unspecified in the process variable myVariable.

You can then use myVariable to perform a lookup in the Data Repository where you will have stored the appropriate template/datamapping config names.

I wasn’t aware of the repo manager in the workflow. Since my lookup value is actually %O. I wouldn’t even need to load a file. How would I write this in javascript to search the data repository by %O and set my myVariable to return key ?

I don’t think that I can use the lookup function like this because I am getting an error of “Lookups’ is undefined”

I have created a group called “Lookups” in the data repository manager.

var dataName,s, results;
s = Watch.ExpandString(“%O”);
dataName =s.substring(0, s.indexOf(‘_’));

results =lookup(Lookups, TemplateName, Masks,dataName);

Watch.SetVariable(“global.dataMapperName”,dataName);

Watch.Log(results, 2);

Replace the lookup line in your code with this one:

results = Watch.ExpandString("lookup(Lookups,TemplateName,Masks,dataName)");

Thank you Phil. I was able to do this with “Set job infos and var”

Var/Info# %{global.TemplateName}

Value : lookup(Lookups, TemplateName, Masks, ‘%{global.FileName}’)

Glad it works.

Note however that you should NOT use a global variable for this because globals are meant to be shared across multiple processes, which means your process could be changing the value to something that another process is not expecting. Best practice is to use a local process variable instead.