IDVault.globalQuery in workflow mapping


Hi Community,

I would like to share my experience working with queries in the workflows. 

It's important to understand that, we have forms and workflows. When we use IDVault.globalQuery, there is one important difference in the use of it on forms and workflows

In the form components, as text fields, button events, and so, we must always specify the component name or "null" instead of it

For example:

var result = IDVault.globalQuery (myTextField,"myQuery",{mySearchedAttribute:"What I'm Looking for"})

or, if you don´t need to make any reference to the form component, in another words, if you don´t need to fill up a component like a text field with the results of your query, you should add "null" in place of the component id

For example

var result = IDVault.globalQuery (null,"myQuery",{mySearchedAttribute:"What I'm Looking for"})

In case of working in the workflow instead, the use of global queries changes a little bit. Imagine if you want to print any return of a query in a log component or in a mapping component

You should use the IDVault.globalQuery like this:

var result = IDVault.globalQuery ("myQuery",{mySearchedAttribute:"What I'm Looking for"})

See that we don´t have reference to any form component on it, even we don´t have to add "null" in the method.

That said, the things become more interesting now. I was struggling a lot in attempt to search for an email that could be already in use, to avoid creating users with same email address.

So, I created a query like this

Key: search_Users_Mail

Entity: User

Parameters: mail

Condition: mail equals %mail%

Search root: ou=users,o=data

Scope: container and sub-containers

In a mapping component of my workflow, I used the query to search for any user that may have the email I was attempting to register

Something like this:

var mailToBeAdded = ""

var usersFound = IDVault.globalQuery("search_Users_Mail", {mail:mailToBeAdded}) //response is an object
var usersFoundString = usersFound.toString();

The response of the query is an Object. When there is any value, it will come the DN of the user, something like this, after do the cast from object to string


If there is no value, in case the query search didn´t find any user with same email, the response will be like this


In this way, I could evaluate if there were people using the same email I would like to add for a user or not.

if (usersFoundString.length == 2) //in case of no values found in the query, the response is []
    result = mailToBeAdded;

else // there is someone with same email alread


//do something else here


By using this strategy, I could solve my problem. We may have other strategies as well, but this was the one that worked for me. Hope it can be helpful for other people as well :)


Customer Stories
How To-Best Practice
Comment List
  • Hello Bruno, I have a similar requirement. Can you specify where to put the javascript code you exampled in this discussion?

    My requirement is this. Once the initiator launches the form, a field in the form should display all the employees belonging to the initiator. In this case the initiator is the manager and a field (possible DN Query) should list all the employees