Global Query in Submit Action

Guys,

I'm trying to do a validation during the submit action in workflow by checking a response from Global query.
form.interceptAction("SubmitAction", "around",
function (invocation)
{
var v=IDVault.globalQuery(null, "UserCheck", {"fN":form.getValue("firstName"), "lN":form.getValue("lastName")})
if(v!=null)
{
var g=v[0];
form.showError("Duplicate Found", g)
return "";
}

var result = invocation.proceed();
return result;
}

When i execute the code it is simply showing the error message all the time unless the condition for GlobalQuery is met or not

Is there any problem in the function created for submit action?

Thanks,
  • Does "UserCheck" match the query key (it's case sensitive) rather than the display name?
    If all looks good, I would do an LDAP trace from the eDir server and see what it's sending...maybe the query is not sending the search string you intend.


    BTW, rather than test my return variables that way, I use a function called "undef()" which does it in a manner less likely to return an exception. To use it in your case replace

    if(v!=null)

    with

    if (!undef(v))

    I believe you also need a space between the if and the parenthesis.

    CODE FRAGMENT
    /* error checking - tests to see if a variable is undefined */
    function undef(v)
    {
    //order here is important because it will stop processing when the first condition that is true in the compound statement is hit. If you try to test v.toString() on an undefined variable you get an exception.
    return (typeof(v) == "undefined") || (null == v) || (v.toString() == "");
    }
  • Keep in mind that globalQuery returns a Vector of DNs when called in the
    workflow, but returns a dual array when called in the browser/form.

    To check if data are returned you can use something like:

    var v=IDVault.globalQuery(..);
    if ( v