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

To remove "Submit for Approval" button from the Approval History related list once case is approved
Hi,
Here is a requirement to remove the button "Submit for Approval" from the Approval History related history list from a case page layout once the case is approved.
I didnt find any settings to remove the button in the page layout properties.
Please share your ideas if you had come across this requirement with any workarounds.
Thanks in advance,
Pavan
I was able to use a sidebar component and jQuery to remove the Submit for Approval button. We needed some custom logic to execute before the record entered the approval process so we added a custom button to submit for approval and removed the submit for approval button on the Approval History section by adding the following sidebar component. Note this will break if Salesforce changes the name of the button component "piSubmit". Replace the ###### with a reference to a static resource with the jQuery.js. You can't use the functions in sidebar components for URLFOR.
All Answers
Not a proper solution but try it.
Remove Submit for Approval button from the related list. I hope in the detail page you have that button. Now create 2 record types - one including that button, another without button. When the approval status(picklist, usually) changes to Approved, change the record type to 2nd type(with the help of workflow).
Done.
Hi Abhi,
Thanks for the reply, that works for the main case page layout. But it doesnot work for the related history page layout "Approval History". Even if i edit this page layout, i willnot get an option to edit/ remove the Button properties for this related list page layout.
Thanks,
Pavan
Ohh yeah, you cannot remove it.
The only solution I can give you for time being is to update the approval entry criteria so that it fires only if the status is not approved ;)
I was able to use a sidebar component and jQuery to remove the Submit for Approval button. We needed some custom logic to execute before the record entered the approval process so we added a custom button to submit for approval and removed the submit for approval button on the Approval History section by adding the following sidebar component. Note this will break if Salesforce changes the name of the button component "piSubmit". Replace the ###### with a reference to a static resource with the jQuery.js. You can't use the functions in sidebar components for URLFOR.
Hi
could you please share the complete code...
Thanks
koushik
Besides a copy of jQuery (or you can link to it see http://docs.jquery.com/Downloading_jQuery) that is really all the code you need. Add that script to any sidebar component and make sure the "Show Custom Sidebar Components on All Pages" in User Interface settings is enabled. The code will look for the Submit for Approval button on page load and hide it from the user. Let me know if you have any more questions on setting it up.
FYI - I used the prefix of the object to selectively remove the button. In our case not all submit for approval buttons needed overriding so this will only hide the button on the object with the prefix 'a14' which is a custom object in our Org.
Thanks,
Alex
Hi
I tried with jquery. But it did not work.
<script src="/resource/Jquery_1_8_11/jQuery"></script>
<script>
$j = jQuery.noConflict();
// Added a check for a specific custom object
if(window.location.href.indexOf(".com/a14") != -1) {
$j(document).ready(function() {
$j("input[name='piSubmit']").hide();
});
}
</script>
src="/resource/Jquery_1_8_11/jQuery is static library in my org. It did not work.
Thanks
koushik
Because sidebar components do not support Visualforce expression language you have to get a URL for the static reference to use in your html. I use the sample visualforce page above to get the URL for a static reference. It should look something like /resource/1310072847010/Jquery_1_8_11. Then use the following snippet for your custom object (a3k) replacing the ######### with the number you found using the sample VF page above.
Note that uploading new versions of the static resource will change this number and you have to rerun the sample VF page and update your sidebar component. I have not found a way to get the static resource using just html (no VF) but I am sure there is a solution out there if someone wants to share it.
Alex
Hi, Alex! Thanks for taking the time to write this up--we're in exactly the same situation, and we have successfully added a custom approval button. I've been unable to get the standard button to hide, however. I'm hoping you or someone might still be looking at this thread and be able to give me suggestions. I don't have any previous experience using jQuery, so that might be where I'm going wrong.
I downloaded a file named 'jquery-1.7.2.min.js' and uploaded it as a static resource called 'jQuery'. I used your Apex cheat to find the URL for this resource, and updated your script to point to that new URL and changed the object prefix to match our object. I can see the component listed in the sidebar, but the standard approval button still appears. Any suggestions? Many thanks in advance!
Never mind! I found that with two changes I was able to get this to work:
Making those two changes got this to work! Thanks again for posting the details, Alex! Now I need to determine what kind of performance impact changing the Separate Loading of Related Lists wil have...
Hi Alex,
Can you guide me on how to add this custom component? I am trying to do something very simliar and can't seem to add the custom component to the side bar. Can you show me the steps to archieve this? thank you very much.
FG
Thanks this worked as a charm !!
Hi Alex,
Below is the code I have used.
My static resource name is 'Hide_Submit_For_Approval_Button_Js'.
I am still not able to hide the button.
Tons of thanks once again...
This is such a wonderful post and I just love this information. We have a requirement to hide "Recall Approval Request" button. This button only appears to our system admins after a record being submitted for approval and if the record is waiting for approval. I am assuming that the same process will work here and I just need to know the button name that I can use in the script. I tried with piRecall / recall but it is of no luck. Appreciate all your assistance.
With the coming SFDC changes, we'll no longer be able to use quick JS hacks like this to solve our little UI issues. HTML will only allow you to use the WYSIWYG editor. Future JS will have to be added as a VF page, which isn't absolutely terrible, except for the cross-domain problem. We're currently investigating that to see if there is any workaround as we really need the ability for navbar JS to add/remove/alter standard UI without having to create new VF pages for every standard layout.
I have a different approach for this issue.
If you want to replace the Submit for approval button in the detail page .
do the following.
Replace the detail page with a vf page as follows.
<apex:page standardController="Object__c" tabStyle="Object__c">
<apex:form id="myForm">
<apex:pagemessages />
<apex:detail subject="{!Object.Id}" relatedList="true" inlineEdit="false" />
</apex:form>
</apex:page>
And in this page add the following script
<script language="JavaScript" type="text/javascript">
var allTdTags = document.getElementsByTagName('td');
for(var i=0;i<allTdTags.length;i++){
if(allTdTags[i].className == 'pbButton'){
document.getElementsByName('piSubmit')[0].style.display = "none";
}
}
</script>
so the final out put code would look like this....
<apex:page standardController="Object__c" tabStyle="Object__c">
<apex:form id="myForm">
<apex:pagemessages />
<apex:detail subject="{!Object.Id}" relatedList="true" inlineEdit="false" />
</apex:form>
<script language="JavaScript" type="text/javascript">
var allTdTags = document.getElementsByTagName('td');
for(var i=0;i<allTdTags.length;i++){
if(allTdTags[i].className == 'pbButton'){
document.getElementsByName('piSubmit')[0].style.display = "none";
}
}
</script>
</apex:page>
This code works fine. This code removes the Submit for approval button form the Details page.
Now you can create your owm custom button replacing this button.
Below is my code on a side bar (home page VF Area component).
<apex:page >
<script src="/resource/1423827610000/jQuery"></script>
<script>
$j = jQuery.noConflict();
if(window.location.href.indexOf(".com/001") != -1) {
$j(document).ready(function() {
$j("input[name='piSubmit']").hide();
});
}
</script>
</apex:page>
But, Submit button still appears on account page. Any mistake I am doing here?
Appreciate any response.