Absent Member.
Absent Member.
472 views

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,
Labels (1)
0 Likes
2 Replies
Highlighted
Honored Contributor.
Honored Contributor.

Re: Global Query in Submit Action

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() == "");
}
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: Global Query in Submit Action

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 && v[0] && ( v[0].length > 0 )) ...

Wolfgang

On 24/07/2018 14:34, Mikey0513 wrote:
>
> 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,
>
>

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.