• Mohamed Ali 20
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
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!
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!