• leloup
  • NEWBIE
  • 25 Points
  • Member since 2010

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 4
    Replies

Did anybody try to reassign approval process in apex code?  I have seen several threads and couple of solutions but no real example. Could anybody post a  piece of working code? That would be very helpfull!!! Thank you a lot in advance!

  • October 21, 2010
  • Like
  • 0

Hello

 

I have popup vf page which is opened by custom button. It uses standard controller with extension. And the problem is that it uses standard save() method and it never closes. I tried to apply solution from here

http://boards.developerforce.com/t5/Visualforce-Development/Closing-Popup/m-p/187900/highlight/true

but it doesn't work. The javascript function is loaded and passes if-condition but the window is not closed. Here is my code, maybe someone have an idea what's the problem is:

<apex:page standardController="Opportunity" extensions="PPOppWonController"
sidebar="false" showHeader="false" standardStylesheets="false" wizard="false" id="pg"  >
  <html>
   <head></head>
<body onload="checkStatus();"></body>
</html>
    <apex:form id="frm" >

        <table>
            <tr>
                <td valign="top">
       
                   <apex:inputTextarea id="sReasonWon" value="{!sReasonWon}" cols="35" rows="5"
                        onkeypress="return disableEnterKey(event)"></apex:inputTextarea>
                        <apex:inputHidden id="stat" value="{!sStatus}" />
                        </td></tr>
                       <tr> <td>
                    <apex:commandButton action="{!save}" id="btn" value="Request Won " />

                </td>

            </tr>
        </table>
        <script>
            var btn = document.getElementById("{!$Component.btn}");  

            var sts = document.getElementById("{!$Component.frm.stat}");
     </script>
    </apex:form>
    <script type="text/javascript">
               
        function disableEnterKey(e)
        {
        var key;
        if(window.event)
        key = window.event.keyCode; //IE
        else
        key = e.which; //firefox
        return (key != 13);
        }       
         function checkStatus(){
                        
                 if(sts.value == 'saved'){
                   
                        self.close();
                  } }
        
      </script>

</apex:page>

Thank you in advance! Any help is welcome

  • October 21, 2010
  • Like
  • 0

Hello

 

I have popup vf page which is opened by custom button. It uses standard controller with extension. And the problem is that it uses standard save() method and it never closes. I tried to apply solution from here

http://boards.developerforce.com/t5/Visualforce-Development/Closing-Popup/m-p/187900/highlight/true

but it doesn't work. The javascript function is loaded and passes if-condition but the window is not closed. Here is my code, maybe someone have an idea what's the problem is:

<apex:page standardController="Opportunity" extensions="PPOppWonController"
sidebar="false" showHeader="false" standardStylesheets="false" wizard="false" id="pg"  >
  <html>
   <head></head>
<body onload="checkStatus();"></body>
</html>
    <apex:form id="frm" >

        <table>
            <tr>
                <td valign="top">
       
                   <apex:inputTextarea id="sReasonWon" value="{!sReasonWon}" cols="35" rows="5"
                        onkeypress="return disableEnterKey(event)"></apex:inputTextarea>
                        <apex:inputHidden id="stat" value="{!sStatus}" />
                        </td></tr>
                       <tr> <td>
                    <apex:commandButton action="{!save}" id="btn" value="Request Won " />

                </td>

            </tr>
        </table>
        <script>
            var btn = document.getElementById("{!$Component.btn}");  

            var sts = document.getElementById("{!$Component.frm.stat}");
     </script>
    </apex:form>
    <script type="text/javascript">
               
        function disableEnterKey(e)
        {
        var key;
        if(window.event)
        key = window.event.keyCode; //IE
        else
        key = e.which; //firefox
        return (key != 13);
        }       
         function checkStatus(){
                        
                 if(sts.value == 'saved'){
                   
                        self.close();
                  } }
        
      </script>

</apex:page>

Thank you in advance! Any help is welcome

  • October 21, 2010
  • Like
  • 0

Hey all,

 

So right now I am having an issue with a popup opened by javascript not closing itself. I am executing the self.close() javascript on the "save" button in the window, but the window simply refreshes itself rather than closing. Does anyone know if visualforce is stopping the close() action, and if so, is there a known workaround to close the popup?

 

Thanks,

Derrek

I'm using a trigger to submit custom object records for approval as soon as they are created.  Here is the code that submits the record(s):

 

 

trigger modSubmitter on Modification__c (after Insert) { Approval.ProcessSubmitRequest[] reqs = new Approval.ProcessSubmitRequest[]{}; for(Modification__c m : Trigger.New){ if(m.Status__c!='Approved'){ Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest(); req1.setObjectId(m.id); reqs.add(req1); } } if(reqs.size()>0) Approval.ProcessResult[] result = Approval.process(reqs); }

 

 

 I then try inserting a record and it fails because an exception is thrown, error is "MANAGER_NOT_DEFINED".  All users involved in the process have managers defined in their user records... plus the approval process doesn't look at the manager field on any users anyhow... it just uses 'related user' lookup fields for all steps.

 

The API docs just say that this error means there is no manager for the approval process, which doesn't help much.  I scoured the Apex guides to see if there were more Approval methods available for somehow defining a "manager" for the request, but there is nothing.

 

Any ideas?

 

We implemented an approval workflow and also approval escalation when initial approver did not respond within 24 hour. However, when we tried to UPDATE the ACTORID for the processinstanceworkitem, we received this error:

 

INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY

 

what permission do we need for the user to be able to update the processinstanceworkitem?

 

Thanks.