OL Learn

Check is entry exisits within Repository

Hi

I want to check if a entry exists for a value within the data repository via script but I can’t see anything to check. I’ve tried doing a .get but it seems to return the value NODATA but I can’t get a IF statement to work looking for this value eg

if (ClientCheck !== ‘’)

or

if (ClientCheck !== ‘NODATA’)

etc

Regards

James

This works just fine on my end:

var repoObject = new ActiveXObject("RepositoryLib.WorkflowRepository");
var myValue = repoObject.GetValue("test", "value", " label='MyLabel' ");

if(myValue!=="NODATA"){
  Watch.Log(myValue,2);
} else {
  Watch.Log("NOTHING TO SEE!",2);
}

thanks this worked, not sure what I was doing before!

Got another query now, trying to get all values using GetKeySets but I can’t get the wildcard to work, I either get no values or a error. The documentation says you can use a wildcard (*) in the condition but whats the syntax as I’ve tired all of the below but not getting anywhere:

var Repo = repoObject.GetKeySets(“UN04001_Configs”, ‘[“CustomerName”],[“PageCount”],[“PackCount”]’, “CustomerName=’’");
var Repo = repoObject.GetKeySets(“UN04001_Configs”, ‘[“CustomerName”],[“PageCount”],[“PackCount”]’, "CustomerName=
”);
var Repo = repoObject.GetKeySets(“UN04001_Configs”, ‘[“CustomerName”],[“PageCount”],[“PackCount”]’, “");
var Repo = repoObject.GetKeySets(“UN04001_Configs”, ‘[“CustomerName”],[“PageCount”],[“PackCount”]’, "’
’”;
var Repo = repoObject.GetKeySets(“UN04001_Configs”, ‘[“CustomerName”],[“PageCount”],[“PackCount”]’, *;

The documentation is incorrect (I have reported it to our documentation team). It should read: “To retrieve all KeySets from a group, you can pass an empty string as the condition”.

So in your case:

var Repo = repoObject.GetKeySets("UN04001_Configs", '["CustomerName"],["PageCount"],["PackCount"]', "");

Note that you could also use a static “dummy” condition like "1=1", but that would just be wasting CPU cycles needlessly.

ah perfect thanks again Phil

@Phil as a side note: It would be also fine if the repository api documentation provides more working examples with variable data. Especially for vbscripts.

Because the Repository API relies so much on JSON structure (which is obviously a native JavaScript format), VBScript is not the most appropriate language for it. Not to mention the fact that VBScript hasn’t been updated in about 15 years, which makes it borderline obsolete.

I strongly recommend you start using JavaScript, especially since the Enhanced JavaScript option was added to the languages available in the Run Script task.