Important Update: Community URLs redirect issues are partially resolved. Learn More. .

cancel
Showing results for 
Search instead for 
Did you mean: 

Unbind AWF buttons?

jsol5
Advocate II

I know it is possible to unbind the onclick event for the Save and Save and Close buttons.

However, I don't seem to be able to do this for the Workflow buttons.

Wondering if this is possible.

 

Ultimately, I want to trigger the event if my criteria is OK, else do nothing.

1 ACCEPTED SOLUTION

Accepted Solutions

Anonymous
Not applicable

I use custom objects to intercept AWF buttons especially when I need to do a Rule check since the AWF error message is generic.  Here is the snippet I use for intercept:

 

//Grab Transition tab info and store it
var TransitionClick = $('a[title="Rejected"]').prop("onclick");
//Resets tab to trigger validation
Sys.Application.add_load(function() {
    //Resets transition tab to validate rules
    $('a[title="Rejected"]').removeAttr('onclick').unbind('click');
    $('a[title="Rejected"]').prop("onclick", null);
    $('a[title="Rejected"]').click(function() {
        ValidateRules();
    });
});    
Then the ValidateRules function does all the checking. If validation succeeds then I exit to TransitionClick() and the record passes through.  To the user when they hit the button a detailed error message pops up if they are missing something otherwise the record saves and transitions on through AWF.

View solution in original post

25 REPLIES 25

Ilya_Khen
Champion III

Oh, very interesting, I thought behaviour is the same here.

I remember some user were able to override action to the WF button: Archer workflow custom object 

 

But if you are checking for the event handlers, have you checked if there are any for mentioned buttons? Some example:

var events = $.data(document.getElementById('master_btnApply'), "events");
var hasEvents = (events != null);

$.each( events, function(i,o) {
     alert(i) // guid of the event
     alert(o) // the function definition of the event handler
});

I hadn't done anything like that..... But, I am going to look at that function to see what I get.

 

Here's what I did:

I basically, through the browser debug tools, attempted the same code I've done with the save and apply.  (...removed existing on click and added new onclick function).

 

So, I can get this base test to work for save and save and continue buttons, no problem.

 

So, then I just replace the element id with the name of one of the workflow buttons. 

I click the AWF button and no message AND it moves it through workflow. 

....Which is annoying on 2 levels.  1. it didn't work, 2. i have to reset my test record lol.

 

What I'd like to do is just create a function that loops through all the AWF buttons and does the prefix event logic.

**Which would be  function dosomething, then if function is false stop the original AWF onclick event if function is true, then continue to process.

*Effectively, I'm running a custom check to validate something that I can't do with Archer OOB.  If it passes validation then continue workflow, if not, then stop user from advancing.

 

However, I haven't, yet been successful in overriding the existing AWF button.  

To be honest, I yet never had demand to override AWF buttons, but there definitely should be the way.

Try the codes in the topic I provided and also check for event handlers.

 

Would be interesting to see, if you make it work. 

 

Thanks, Jason!

Same here.  Never wanted to mess with the buttons.

However, I have code that compares to user list fields.  And, I'm not in love with it because it's using an interval to check rather than off of an actual button click or dropdown click event.

 

So... Maybe you're unsure about overriding the AWF button, but have you captured a user/group list field change event?   

I believe I seen David was answering this long time ago:

https://community.rsa.com/thread/192243 

MutationObserver?? lol ... Uh yeah, so I may have better luck with overriding AWF button clicks or keeping it to using setinterval.

 

btw - 

$._data( document.getElementById("master_2955:CUST"), "events" ); 

results in undefined.

for save buttons, it gives me the click event object.

Yeah, meaning that there is no hidden event handlers defined for the button except what is defined for onclick.

E.g. buttons in BCM module had some event handlers which were running even if you defined your own onclick property there.

 

Then basically overriding onclick attribute for the AWF button should work in theory.

For now, I think I'm going with mutationobserver.  I did a small test and was super simple.

Thanks!

Great!  I initially was a bit wondering if this would be working in all browsers, and IE especially, but if you did testing, seems okay

And this one is also showing good except Opera mini