1 min read time

Handling Form Queries with IDM UserApp

by in Cybersecurity

Problem



A Forum reader recently asked:



"On a event, I'm doing a query for a user object. If the query does not return an empty string, I want to put a form.alert. The query looks like this:



var v = IDVault.globalQuery("idesist", "QUser", {LOGINID:form.getValue("loginid")});



How do I check for the return to be non-empty and the user to get the function form alert?"



And here's the response from Rudy Duym ...



Solution



This expression:



var v = IDVault.globalQuery("idesist", "QUser", {LOGINID:form.getValue("loginid")});



returns an array with 2 entries, each being also an array of values. The result will also be stored in the field "idesist", which corresponds to the first parameter value.



The first entry on the array contains the dn values returned by the query. You get the first value of this array with a v[0][0]. You can also loop over the values, of course.



The second entry contains the cn part of the dn values returned by the query. You get the first value of this array with a v[1][0].



So if you want to test whether a non-empty value was returned, you can use something like this:



      var v = "";
try {
v = IDVault.globalQuery("idesist", "QUser", {LOGINID:form.getValue("loginid")});
} catch (e) {};
if (v.length > 0 && v[0].length > 0 && v[0][0] != "") {
// non empty result
}



Note: As a field destination is specified, the result of the query will also be automatically stored in the field "idesist"!

Tags:

Labels: