Knowledge Partner
Knowledge Partner
376 views

Form script, interceptAction question

I have been using the interceptAction in a Form to do 'stuff' when the
user clicks on Submit.

The docs on page:
https://www.netiq.com/documentation/idm402/dgpro/data/palecmaecmaapi.html

For this function explain:


InterceptAction(actionname, order, function)

form.interceptAction("actionname", "order", "function")

Allows you to intercept the script attached to an action button. The
function passed in is executed based on the order parameter.

Valid actionname values are SubmitAction and CancelAction.

The choices for actionname for an approval form are: ApprovalAction,
RefusalAction, DenyAction, UpdateAction, CancelAction and
CommentAction.Valid values for the advice parameter are:Before: The
function is called before the script attached to the button
executes.after: The function is called after the script attached to the
button executes.around: The function is passed a parameter that allows
you to decide whether to execute the script attached to the button The
following example shows the submit action intercepted. The form is only
submitted if the user replies Yes.

window.inv=function (invocation) { if (confirm( "Are you sure you want
to submit?")) { var result = invocation.proceed(); return result; }; };

form.interceptAction("SubmitAction", "around", window.inv);




Ok, I have a working example, but I have many questions remaining.
Which is my usual issue with the docs. I need better and more examples.
All values and options need to be listed in the docs. After all, where
else do you go, to find out such things?

1) invocation.proceed() makes sense, and allows the Submit to proceed.
What other alternate functions are there? Can I fail to proceed? If
so, what is the format for that?

2) Is there a way to take a click on Submit, (intercept the action) and
then if the test fails, then cancel the entire form? What, other than
proceeding, can I do with this function? What happens if I do not send
a .proceed()?


Labels (1)
0 Likes
3 Replies
Anonymous_User Absent Member.
Absent Member.

Re: Form script, interceptAction question

On 02.10.2013 16:06, Geoffrey Carman wrote:
> I have been using the interceptAction in a Form to do 'stuff' when the
> user clicks on Submit.
>
> The docs on page:
> https://www.netiq.com/documentation/idm402/dgpro/data/palecmaecmaapi.html
>
> For this function explain:
>
>
> InterceptAction(actionname, order, function)
>
> form.interceptAction("actionname", "order", "function")
>
> Allows you to intercept the script attached to an action button. The
> function passed in is executed based on the order parameter.
>
> Valid actionname values are SubmitAction and CancelAction.
>
> The choices for actionname for an approval form are: ApprovalAction,
> RefusalAction, DenyAction, UpdateAction, CancelAction and
> CommentAction.Valid values for the advice parameter are:Before: The
> function is called before the script attached to the button
> executes.after: The function is called after the script attached to the
> button executes.around: The function is passed a parameter that allows
> you to decide whether to execute the script attached to the button The
> following example shows the submit action intercepted. The form is only
> submitted if the user replies Yes.
>
> window.inv=function (invocation) { if (confirm( "Are you sure you want
> to submit?")) { var result = invocation.proceed(); return result; }; };
>
> form.interceptAction("SubmitAction", "around", window.inv);
>
>
>
>
> Ok, I have a working example, but I have many questions remaining. Which
> is my usual issue with the docs. I need better and more examples. All
> values and options need to be listed in the docs. After all, where else
> do you go, to find out such things?
>
> 1) invocation.proceed() makes sense, and allows the Submit to proceed.
> What other alternate functions are there? Can I fail to proceed? If so,
> what is the format for that?
>
> 2) Is there a way to take a click on Submit, (intercept the action) and
> then if the test fails, then cancel the entire form? What, other than
> proceeding, can I do with this function? What happens if I do not send a
> .proceed()?
>
>


Hi Geoff,

yes, there are some gaps in the docs. That give you the chance for some
nice CoolSolutions.

1) Instead of returning "invocation.proceed()" from your intercept
handler, simply return "false"

function (invocation)
{
if ( confirm( "Are you sure?"))
return invocation.proceed();
else
return false;
}


2) Nothing official, but see my suggestion in the "Self Destruct" thread.

Good luck

Wolfgang

0 Likes
Knowledge Partner
Knowledge Partner

Re: Form script, interceptAction question

On 10/2/2013 1:06 PM, Wolfgang Schreiber wrote:
> On 02.10.2013 16:06, Geoffrey Carman wrote:
>> I have been using the interceptAction in a Form to do 'stuff' when the
>> user clicks on Submit.
>>
>> The docs on page:
>> https://www.netiq.com/documentation/idm402/dgpro/data/palecmaecmaapi.html
>>
>> For this function explain:
>>
>>
>> InterceptAction(actionname, order, function)
>>
>> form.interceptAction("actionname", "order", "function")
>>
>> Allows you to intercept the script attached to an action button. The
>> function passed in is executed based on the order parameter.
>>
>> Valid actionname values are SubmitAction and CancelAction.
>>
>> The choices for actionname for an approval form are: ApprovalAction,
>> RefusalAction, DenyAction, UpdateAction, CancelAction and
>> CommentAction.Valid values for the advice parameter are:Before: The
>> function is called before the script attached to the button
>> executes.after: The function is called after the script attached to the
>> button executes.around: The function is passed a parameter that allows
>> you to decide whether to execute the script attached to the button The
>> following example shows the submit action intercepted. The form is only
>> submitted if the user replies Yes.
>>
>> window.inv=function (invocation) { if (confirm( "Are you sure you want
>> to submit?")) { var result = invocation.proceed(); return result; }; };
>>
>> form.interceptAction("SubmitAction", "around", window.inv);
>>
>>
>>
>>
>> Ok, I have a working example, but I have many questions remaining. Which
>> is my usual issue with the docs. I need better and more examples. All
>> values and options need to be listed in the docs. After all, where else
>> do you go, to find out such things?
>>
>> 1) invocation.proceed() makes sense, and allows the Submit to proceed.
>> What other alternate functions are there? Can I fail to proceed? If so,
>> what is the format for that?
>>
>> 2) Is there a way to take a click on Submit, (intercept the action) and
>> then if the test fails, then cancel the entire form? What, other than
>> proceeding, can I do with this function? What happens if I do not send a
>> .proceed()?
>>
>>

>
> Hi Geoff,
>
> yes, there are some gaps in the docs. That give you the chance for some
> nice CoolSolutions.


Ya, cuz I am clearly lacking in material to write about, and have the
copious spare time to write more. (And they are releasing WAY Too slow
for my taste. I have 17 articles in queue, waiting to be published... Meh).


> 1) Instead of returning "invocation.proceed()" from your intercept
> handler, simply return "false"
>
> function (invocation)
> {
> if ( confirm( "Are you sure?"))
> return invocation.proceed();
> else
> return false;
> }


That seems like the default. But the question is for "return
invocation.proceed()", are there any other options?

If there were, how would one figure that out?

> 2) Nothing official, but see my suggestion in the "Self Destruct" thread.


I am stuck with a Redirect to another web page right now. That works,
but maybe not what i really wanted...



0 Likes
Anonymous_User Absent Member.
Absent Member.

Re: Form script, interceptAction question


Noticed the Cancel Button calls the javascript:backToList()

Was able to simulate the Cancel button with an HTML control type:

(function () {return "<a href=# onclick=backToList();return
false;>Cancel</a>" ; } ) ();

Gary


--
gholdefe
------------------------------------------------------------------------
gholdefe's Profile: https://forums.netiq.com/member.php?userid=318
View this thread: https://forums.netiq.com/showthread.php?t=48830

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.