You need to sign in to do that
Don't have an account?

How to Approve the record through Apex Programming.
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
You need to go through processInstance records.... I have some code which I'll put here which may help... it's pulled out of a large VF controller which presented a list of Items for approval (Items to be Distributed to customers). I put a bunch of checkboxes on the page next to the item information so the user could select which ones to approve.
So, this is a subset of the controller which, perhaps, will help.
First, define a helper class for the approvals on my Distributed_Items__c objects.
Load my outstanding approvals... so ItemsForApproval can be used in a pageBlockTable to display information about the object as well and the acceptance and rejection etc.
Go through them and do the approvals the user has requested...
The portion of the page with the VF about Approvals...
Note that I'm not 100% certain this covers every case, etc. but it did the portions that we needed. And, I've extracted this out of a larger controller, so there may be some hanging references. Either way, hope this helps to explain it... Best, Steve.
Thanks for your Solution.Can you please let me know if it is possible to navigate the user to visual force page upon clicking Approve/Reject link on the relatedlist of the detail page of the record instead of navigating standard Approve/Reject page.
I am facing this Error
System.DmlException: Process failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []
please help me to resolve this