Monday, October 31, 2011

Submit for Approval Button

The other day I was looking for a way to create a button for submitting a record for approval I wanted to do this so that I could have it on the top of the record instead of in the related lists. I found a bit of java script that allows me to do this in a custom button. For those of you that are looking to do this it's very easy to do. Here's how:


  1. Go to your object and select the Buttons and Links section.
  2. Click to Create a New button.
  3. Give the button a name
  4. Choose a Detail Page Button 
  5. Select Execute JavaScript as the behavior.
  6. Select OnClick JavaScript as the Content Source
  7. In the code area enter the following code block. *Please note that you can edit the pop alert text to fit your scenario as well as change the name of the object to the object you would like to work with. In this example, I am using the Case object as an alternative means for escalating cases.*

    {!REQUIRESCRIPT('/soap/ajax/23.0/connection.js')}
    
    if ((Modal.confirm && Modal.confirm('Once you escalate this case, you must recall the approval before you can edit it. Continue?')) || (!Modal.confirm && window.confirm('Once you submit this case, you must recall the approval before you can edit it. Continue?'))) navigateToUrl('/p/process/Submit?id={!Case.Id}&retURL=%2F{!Case.Id}');
    

  8. Finally Add the button to the page layout.
Please note that this button will only work if you have an approval process setup for the object that you are creating it on. If there is not one, the button will obviously not submit the record through an approval process that does not exist. 

No comments:

Post a Comment