• Jerry.ax1540
  • NEWBIE
  • 30 Points
  • Member since 2012

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

Hi 

 

how can we get the index of the selected row from the page Block table to the apex class ,

I am Facing the problem when  i am Approving the Submited Approval  through Apex code 

and i am countered with this error pl help me out .

 

System.DmlException: Process failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id

 

 

public void Reject (){

update perform;
Approval.ProcessWorkitemRequest req2 = new Approval.ProcessWorkitemRequest();
req2.setComments('Rating are not up to the mark');
req2.setAction('Reject'); //This is the action that is approve in your case, you can set it to Reject also

req2.setNextApproverIds(new Id[] {UserInfo.getUserId()});
// Use the ID from the newly created item to specify the item to be worked

req2.setWorkitemId(perform.id);

// Submit the request for approval

Approval.ProcessResult result2 = Approval.process(req2);
System.assert(result2.isSuccess(), 'Result Status:'+result2.isSuccess());

System.assertEquals(
'Approved', result2.getInstanceStatus(),
'Instance Status'+result2.getInstanceStatus());

}

 

 

Hi 

 

 i  created a visual force page with standard list view,its having list of records,for suppose  i opend the particular record ,i want to go back to the priveious list of records,can any one suggest me how to acheive this

Hello Everyone,

 

i had used apex:param tag quite a lot by now,but so many times i noticed if name attribute is not specified it is not working properly.

 

So i guess it's like key for the value which we want to assignto a property of a controller. 

 

please do correct me if i am wrong...

 

Sravan Alaparthi.

 

 

Hi 

 

how can we get the index of the selected row from the page Block table to the apex class ,

I am Facing the problem when  i am Approving the Submited Approval  through Apex code 

and i am countered with this error pl help me out .

 

System.DmlException: Process failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id

 

 

public void Reject (){

update perform;
Approval.ProcessWorkitemRequest req2 = new Approval.ProcessWorkitemRequest();
req2.setComments('Rating are not up to the mark');
req2.setAction('Reject'); //This is the action that is approve in your case, you can set it to Reject also

req2.setNextApproverIds(new Id[] {UserInfo.getUserId()});
// Use the ID from the newly created item to specify the item to be worked

req2.setWorkitemId(perform.id);

// Submit the request for approval

Approval.ProcessResult result2 = Approval.process(req2);
System.assert(result2.isSuccess(), 'Result Status:'+result2.isSuccess());

System.assertEquals(
'Approved', result2.getInstanceStatus(),
'Instance Status'+result2.getInstanceStatus());

}

 

 

How do I get the row number back from my PageBlockTable with javascript or jQuery? I’ve tried a few methods, but they always return [object Object].

 

I am displaying repeating elements in a PageBlockTable. When I change the contents of Field1, I want to perform a calculation in my controller, and place the cursor in Field2.

 

Yes, I know the scripting looks like I'm lost - I am. 

 

<apex:page controller="TestTabbingController" id="PageId">

<apex:includeScript value="{!URLFOR($Resource.jQuery, '/js/jquery-1.8.2.min.js')}"  />
<apex:includeScript value="{!URLFOR($Resource.jQuery, '/js/jquery-ui-1.8.24.custom.min.js')}"  />
<apex:stylesheet value="{!URLFOR($Resource.jQuery, '/css/ui-lightness/jquery-ui-1.8.24.custom.css')}"  />


<script type="text/javascript">
	  j$ = jQuery.noConflict();
	  
	  function putErThereDude()
	  {
	  
         var myRow = j$('[id*=PageBlockTableId]');
		 alert("myRow is " + myRow) ; 
			   
	     var Part1 = "PageId:FormId:PageBlockId:PageBlockSectionId:PageBlockTableId:";
		 var myRow = j$('[id*=PageBlockTableId]');
		 var Part3 = ":Field2" ; 
		   
		 var PutIt = Part1 + myRow + Part3; 
		 alert("PutIt is " + PutIt) ; 
		   
		 var myElement = document.getElementById(PutIt);
         alert("myElement is " + myElement) ; 
           
         j$(myElement).focus();		   
	  
	  }


</script>

   <apex:form id="FormId">
      
      
      <apex:PageBlock title="Confirmation" id="PageBlockId">  
     
      
         <apex:PageBlockSection title="GPS Print Products" id="PageBlockSectionId" columns="1" >

               
               <apex:pageBlockTable value="{!OpportunitiesWithIndex}" var="oppWrapped" style="width:100%" id="PageBlockTableId">
               
                
                    <apex:column headerValue="Name" Id="GPSD_Name">
                        <apex:outputLabel value="{!oppWrapped.opp.name}"                 id="Name" >     
                        </apex:outputLabel>                        
                    </apex:column>

                    <apex:column headerValue="Field 1" Id="GPSD_Field1">
                        <apex:inputField value="{!oppWrapped.opp.X_Field_1__c}"          id="Field1" >
                            
                            <apex:actionSupport event="onchange" action="{!doSomething}" reRender="PageBlockSectionId" oncomplete="putErThereDude(event.target.focus())" />
                        </apex:inputField>                           
                    </apex:column>     


                    <apex:column headerValue="Field 2" Id="GPSD_Field2">
                        <apex:inputField value="{!oppWrapped.opp.X_Field_2__c}"          id="Field2" >     
                           <apex:actionSupport event="onchange" action="{!doSomething}" reRender="PageBlockSectionId" />   
                        </apex:inputField>                         
                    </apex:column>

                    <apex:column headerValue="Field 3" Id="GPSD_Field3">
                        <apex:inputField value="{!oppWrapped.opp.X_Field_3__c}"          id="Field3" >     
                           <apex:actionSupport event="onchange" action="{!doSomething}" reRender="PageBlockSectionId" />     
                        </apex:inputField>                         
                    </apex:column>

                    
                    <apex:column headerValue="Field 4" Id="GPSD_Field4">
                        <apex:inputField value="{!oppWrapped.opp.X_Field_4__c}"          id="Field4" >       
                           
                        </apex:inputField>                         
                    </apex:column>
                    
               
                
                
                </apex:pageBlockTable>
                
                


         </apex:PageBlockSection>
        
      </apex:PageBlock>
      
 
   </apex:form>
</apex:page>

 

I have an approval process on a custom object that when submitted, the user submitting the record manually selects the approver in each step.  Based on the requirements, the object is set to private.  So, I need to write a trigger that will manually create read-only access to the approvers.  I can create the read-only access sharing using apex code, but where I'm having trouble is with the ApprovalProcess classes.

 

I only want the trigger to fire when the record has been submitted for approval and the approval step is going to an approver.

 

It looks like I need to use the ProcessWorkItem and ProcessRequest classes.  I can use the getNextApproverIds method to get the user Id of the approver to set the read-only access, but how do I identify if the record has been submitted for approval and is in a step to be approved?

 

Does anyone have a code sample?  I've googled and found some examples of how to submit the record for approval using Apex, but I didn't find anything that shows how to identify the record was submitted for approval and getting the user Id of the next approver.

 

Thanks.

Hi,

 

I have approval process created in salesforce.But according to the requirement user need to enter Approval/Rejection reason before he approves or rejects the record.Hence I have created custom button for Submit for approval,Approve and Reject button with VF page.

 

I know how to create approval request record through apex programming.I want to update the the approval request record created,  once the user clicks on  custom Approve button on  VF page.Can anyone please tell me is it possible to update the approval request record through programming.

 

 

Thanks,

Srilakshmi B

 

 

I am having trouble finding a way to populate error messages to my visual force page. I would like to add a (custom) error message to a inputText on my visual force page like standard behaviour(red lines, and red error message). What I can accomplish is adding it to the top of the page, but how should I add it to one specific field(inputText or inputField)?

 

VF:code:

<apex:page>
<apex:form>
<apex:messages /> <!-- This is showing the errormessage at top -->
<apex:pageBlock mode="detail">
<apex:pageblockSection id="search" columns="1" rendered="{!editModus}">
<apex:outputLabel value="Value"></apex:outputLabel>
<apex:inputText value="{!aValue}"></apex:inputText> <-- HERE I WOULD LIKE TO have the error messages
<apex:commandButton value="Validate" action="{!validate}"/>
</apex:pageblockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 And (a part) of my controller, now it adds the errormessage, but it is shown on top of the page

 

    public void validate() {
// other logic. I add a message to the page, but how can I add it to the input text
ApexPages.Message message = new ApexPages.message(ApexPages.severity.ERROR,'An error message.');
ApexPages.addMessage(message);
}