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
Mohamed Ali 20Mohamed Ali 20 

errors calling two actionFunctions in apex

I'm trying to call 2 methods from my controller within the VF apex code. Having no end of issues.

Here's my code:

   
<apex:page standardController="Account" extensions="AccountController" action="{!SendEnvelope}">
        <apex:form >
             
            <apex:actionFunction action="{!SendEnvelope}" name="SendEnvelope" oncomplete="EmbeddedSign();" />        
            <apex:actionFunction action="{!EmbeddedSign}" name="EmbeddedSign"/>    
            <apex:pageMessages />            
        </apex:form>
               <script>
                  EmbeddedSign();    //oncomplete="EmbeddedSign();"
            </script>   
    </apex:page>


    
I get that having *action="{!SendEnvelope}"* in the root page level will negate my actionFunction, but that's the only way i could get it working.

I've tried the following and failed:

ERROR: 'Attempt to de-reference a null object'
 
<script>           
          SendEnvelope();            
          EmbeddedSign();
    </script>



Or simply having a 'main' function within my controller that in call in apex. 

ERROR: You have uncommitted work pending. Please commit or rollback before calling out

   
public PageReference Main() {
      SendEnvelope();
      EmbeddedSign();
  }



So my assumption based on researching is that i need two separate transactions (callout ordering issues). That's why i have two functions that i need to call separately.

The above code actually gets it working, but it just keeps on reloading and reloading. i'm guessing it's because i'm missing 'rerender', but i couldn't get them working.

I briefly tried @future - that could be my solution, but i needed to return PageReference for the redirect to work in the second function (EmbeddedSign). Although am open to alternatives for sure.

I've hit a wall here, been trying to debug this for way too long. If anyone can please take a look at my code and provide suggestions that would be amazing. Thanks!
Foram Rana RForam Rana R
HI,

There is maybe name conflict name you please rename actionfunction name EmbeddedSign() to EmbeddedSignJS()

 
Mohamed Ali 20Mohamed Ali 20
Thanks. I just tried that, still not working.
Sharon JackSharon Jack
I really happy found this website eventually. Really informative and inoperative, Thanks for the post and effort! Please keep sharing more such blog   Routerlogin (https://routerloginnet.tips/)