OL Learn

Check Repository in Text Condition

I would like to use the repository to check a value is present.
If the value is present then I do not want to send the email.

I probably have the syntax incorrect.

From the Help:

The syntax of the Lookup function is:
Lookup(Group_Name, Key_To_Retrieve, Key_To_Match, 'Value_To_Match')

So in your case, you want to use something like this:

lookup(POs, PO_Number, PO_Number, '%{sPO_Number}')

Thanks, I don’t know why I didn’t notice the ID in the string.
Had to reverse my operator, but this seems to be working.

Now need to build out the other process to update the repository list so it can be controlled by dropping a file into a folder.

Is it possible to use to return the value if both Column A matches %{variable1} and Column B matches %{variable2}, but not one or the other?

Like in SQL… WHERE [Column A] = ‘%{variable1}’ AND [Column B] = ‘%{variable1}’

You can just chain the various lookups in a single statement and have your condition check whether the entire result contains NODATA or not:


Okay, I’ll try that.

With the Delete script

var sPO_Number = Watch.GetVariable("sPO_Number");
var Repo = new ActiveXObject("RepositoryLib.WorkflowRepository");
var deletedCount = JSON.parse(Repo.RemoveKeySets("Email_Exceptions","PO_Number = '" + sPO_Number + "'"));
var answer = (deletedCount > 0) ? "true" : "false";
Watch.SetJobInfo(9, answer);

How would I only delete if both match?

Repo.RemoveKeySets("Email_Exceptions","PO_Number = '" + sPO_Number + "'"));

This should do it:

var sPO_Number = Watch.GetVariable("sPO_Number");
var sPO_Value = Watch.GetVariable("sPO_Value");

var Repo = new ActiveXObject("RepositoryLib.WorkflowRepository");
var removeStatement = "PO_Number = '" + sPO_Number + "' and PO_Value = '" + sPO_Value + "'";
var deleteCount = Repo.RemoveKeySets("Email_Exceptions",removeStatement)
var answer = (deletedCount > 0) ? "true" : "false";
Watch.SetJobInfo(9, answer);

By the way, if you’re comfortable with scripting, you could use a similar syntax to create a script condition that looks up both field values at once (using GetKeySets()), which was your original question.

Works great but minor typo.

var deleteCount should be var deletedCount

On this one I’m supposed to limit the scripts per the business owner.
Can’t avoid all of them, but attempting to keep things in the GUI.

However something like this?

var sPO_Number = Watch.GetVariable("sPO_Number");
var sAcct_Number = Watch.GetVariable("sAcct_Number");

var repoObject = new ActiveXObject("RepositoryLib.WorkflowRepository");
var lookupReply = repoObject.GetKeySets("Email_Exceptions",'["PO_Number","Acct_Number"]',"PO_Number = '" + sPO_Number + "' and Acct_Number = '" + sAcct_Number + "'");
lookupReply = lookupReply.replace('[', '').replace(']', '')

if(lookupReply == ''){
        Script.ReturnValue = 1;
} else {
        Script.ReturnValue = 0

Yup. Gives you much more flexibility in managing the conditions, instead of potentially having to string several conditions in a row in your process.
I do understand the requirement to keep scripts to a minimum, however. So it’s up to you to strike the proper balance.