I have following code:

function PQRS(event,ID){
    if('{!isTrue}' == 'true'){
        alert('DO not have any controls to DELEGATE');
    return false;

Here delegateResult is an action function, and isTrue is variable getting set in delegateResult. But when I call this javascript function, an alert comes up before complete execution of the action function. What should be done in this case?

  • Can you add the VF code as well from where this function is called and actionfunction part as well?
    – RajeshShah
    Dec 20 '16 at 7:07

You need to execute the alert and other stuffs in the oncomplete method. Like this:

<apex:actionFunction name="delegateResult" action="{!delegateResult}" rerender="myForm" oncomplete="afterCompletion">

Then in your javascript code:

function afterCompletion() {
    var isTrue = $("#is_true_element).val();

Please also note I have used a html tag to get the isTrue value. If it is not on the page yet, it should be something like an <apex:inputHidden> tag which is rerendered during the actionFunction.

Please Note that {!isTrue} won't rerender in your javascript code. So you will have to place it in the html and rerender that part.

  • hey i have one question in onComplete action i want to call another function which will open popup..!!!it has more than 7 arguments and the values are coming from repeater. so i have to take 7 variables..but i can not take variables because of view state issue...!!!!can we have another option ? Dec 20 '16 at 7:33
  • @ChintalSomaiya Unless your view state limit is already used up or the 7 parameters are too large, I don't see it as a huge issue here. However, you can still refer to Javascript remoting if you are really worried about the view state size:developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/…
    – Lance Shi
    Dec 20 '16 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.