function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ram Manohar GRam Manohar G 

Oncomplete action function Condition Visualforce

Hi , plz help on this
I have two action function, onclick of 'Next'  it invokes 'insertrecord'  actionfunction which run same controller method  the onComplet of this i am invoking 'doCallout' method using second action function.
Now i want to stop second action function  if there is an catch exception in doInsert() and run only if runaction==true . How to do it.

<apex:actionFunction name="InsertRecord" action="{!doInsert}" Rerender="Status1"
    status="Status1" oncomplete="doCalllout()"/>

   <apex:actionFunction action="{!doCalllout}" name="doCalllout" 
    reRender="opanel" status="Status2"/>

Controller:
public void doInsert()
{
  try{
   runaction=true;
}
 catch
{   
    runaction=false;
  -----ApexpageMessage-----; 
}
}
}
sachin kadian 5sachin kadian 5
Do it with a scriot..
<apex:actionFunction name="InsertRecord" action="{!doInsert}" Rerender="Status1"
    status="Status1" oncomplete="callOrNoCallCallout()"/>

   <apex:actionFunction action="{!doCalllout}" name="doCalllout" 
    reRender="opanel" status="Status2"/>


<script>
   function callOrNoCallCallout(){
          if({!runaction})
         doCalllout();
}
</script>

Controller:
public void doInsert()
{
  try{
   runaction=true;
}
 catch
{   
    runaction=false;
  -----ApexpageMessage-----; 
}
}
}
Ram Manohar GRam Manohar G
I am unable to get the updated  runaction value from controler , it's always showing false the default value
Ram Manohar GRam Manohar G
Hi,
The issue is, I am unable to display catch message bcz the second action method is calling and loading new page. How can i invoke second one on some condition ?
 
sachin kadian 5sachin kadian 5

first set runaction = false , in the try block, after insertion and before return statement make it true . If there is any exception means in catch block again make it false.