0

My client requires to remove submit for approval button once the record is recalled.

We have a triger that forces record to move to submit for approval depending on the stage status. and approval process critearea is has to be at certain stage to allow submit for approval .

So once it is recalled the status changes to the lower level and at that point submit for approval thing does not work because not meeting the criteria of approval process.

So I need that button to be removed completly once the record is recalled.

2
  • 1
    You can't without rolling your own related list / object / buttons
    – Eric
    Jul 23, 2015 at 16:42
  • Or use a VF page with apex:detail and some jQuery to hide the button once recall takes place (will require a field update to set a custom field 'is_recalled__c` to true
    – cropredy
    Jul 23, 2015 at 18:08

1 Answer 1

1

Thanks to this wizard's answer in the below question, based on which I am framing my answer to pull of this trick (Do not blame if SF stops supporting or jacks up JS support as they did with home page components):

Changing the color of a custom button

Step 1: Create a fake submit for approval (or) name it anything you want

Step 2: I have the logic to hide the button based on stagename, you can use your any field and make this button disappear conditionally on page load.

Paste this javascript in the base64 encoder

http://rot47.net/base64encoder.html

(function() {
var buttontohide = document.getElementsByName('submit')[0];
var fakesubmitbutton = document.getElementsByName('submit_for_approval_custom')[0];
var stage = $("[id$=opp11_ileinner]").text();
buttontohide.style.visibility = 'visible';
fakesubmitbutton.style.visibility = 'visible';
if(stage== "Prospecting"){
  buttontohide.style.display= "none";
  fakesubmitbutton.style.display= "none";
}
else{
fakesubmitbutton.style.display= "none";
}
}());

Step 3: Add this new button to the page layouts of the users who you wish to disable the submit for approval button.

Button syntax should look like : enter image description here

Final output:

when stage = prospecting ( submit for approval is not visible)

enter image description here

when stage != prospecting the submit button is visible. enter image description here

5
  • Hi Rao first of all thanks for all your hard work. I have tested the java script you gave but after adding that java script and to my button and when I click on that button it is giving me an error here is the error details " A problem with the OnClick JavaScript for this button or link was encountered:" I have done exactly what you have instructed here. Can you please able to give me the reason for this ?
    – Ricky
    Jul 23, 2015 at 19:36
  • @ricky the code may or may not work depending on where you are pasting the JS, I have designed this for opportunity object, if you can get on the chat rooms may be I can guide you if not its kinda hard
    – Rao
    Jul 23, 2015 at 20:39
  • you have 24,i see u in the chat
    – Rao
    Jul 23, 2015 at 20:53
  • Hey rao Sorry to interupt you again. I am having defficulty with this script. Can you ping me once you are online.
    – Ricky
    Jul 24, 2015 at 13:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .