Hide the "Submit for Approval" button in the Related List in Salesforce-Solutions and Practice

tags: Js hack  Remove Submit for Approval

[Scenario description]: During the configuration or development approval process, the business often needs to verify the current order status when clicking the Submit Approval button, and prompt the customer under what conditions to submit for approval. The usual practice is to customize the submit approval button, execute the js method, and call the verification logic of the webservice.
[Platform Features]: In Salesforce, the approval history related list on the standard pageThe submit approval button cannot be removed by configuration

Based on the previous introduction, we will face an awkward problem: the custom button is displayed on the Detail page, and the standard button is displayed on the Related List page. Once the user clicks the button on the Related List, the custom button is placed on it. Appears to be deceiving himself.

【How to do?-Routine】

Usually we will control the access conditions by setting the initial submitter of approval as a super administrator or adding a checkbox, So that no matter what conditions the business personnel click on the button on the Related List will enter the invalid access rights page.
Use the checkbox method ideas
a. Create a new checkbox field (whether it is a standard approval button), the default is unchecked;-If the default is checked, the historical data will not be checked.
b. Configure the access conditions, only when this field is true, access is allowed;
c. Set req.setSkipEntryCriteria(true) in the code to skip the entry condition.
Update: by180511, the above routine is too low, just use the formula to change the admission condition to false,as follows:

Do things >=<-As a Virgo, how can I tolerate the above solution? So began to explore other possibilities...

1. Customize a VF page (only include approval history related list), and then use Js Hack to hide the button in VF;
[Effect Preview]:

【Step by Step】:
a. Develop VF logic code:

<apex:page standardController="ApprovalTest__c">
    <script src="https://code.jquery.com/jquery-2.x-git.min.js"></script>
    <script>
        $j = jQuery.noConflict();
        console.log(window.location.href);
        console.log(window.location.href.indexOf(".com/a0C"));
        console.log(window.location.href.indexOf(".com/a0C") != -1);
        if(window.location.href.indexOf(".com/a0C") == -1) {
            $j(document).ready(function() {    
                $j("input[name='piSubmit']").hide();
            });
        }
    </script>
    <apex:relatedList list="ProcessSteps" id="customApprovalList"></apex:relatedList>
</apex:page>

b. Add the page VF to the page layout:

After that, you make it.

2. Inject Js into the sidebar of Home Page and hide the submit approval button on the Related List through Js hack;

I have already gone through solution here Display "Submit for Approval" button in the Approval History related list based on condition but since new release summer 15 home page component no more supports JS , so that does not worked for me.
I can’t help but feel sad to see the above sentence. After summer 15, js cannot be added to the html-type home component.

【step by step】:
a. Custom injection Custom Links;-Note the reference of static resources

{!REQUIRESCRIPT("/resource/1402932484000/JQuery320")} 
$j = jQuery.noConflict(); 
if(window.location.href.indexOf(".com/a0C") != -1) { 
$j(document).ready(function() { 
$j("input[name='piSubmit']").hide(); 
$j(".relatedProcessHistory .pbHeader h3").css('padding', '8px 0'); 
}); 
}

 

b. Add injection custom link in the custom Link type homepage component;

 

c. Enable the injection-box custom component in the homepage layout.

[Effect preview]:

In the end, you will find that in this way you need to click on the sidebar custom link to achieve the hidden effect.

3. It is not feasible to add js code to the VF type home page component. Reason: Can't operate dom fast iframe.

[Summary]: The configuration method is recommended first, followed by method 1.

Reference materials:
https://salesforce.stackexchange.com/questions/38918/end-of-javascript-sidebar-workarounds-salesforce-classic-aloha#comment144978_98915
https://help.salesforce.com/articleView?d=70130000000NIyh&eid=singlesend&id=Message-Alerts-and-Custom-Links-Home-Page-Components-changes&language=en_US&type=1

Intelligent Recommendation

Attribute &amp;quot;alisa&amp;quot; must be declared for element type &amp;quot;typeAlias&amp;quot;.

Learning mybatis, just started writing profiles mybatis-config.xml ,, when the top copy and paste alisa error: Attribute "alisa" must be declared for element type "typeAlias" Worka...

The declared package &amp;quot;com.how2java.j2se&amp;quot; does not match the expected package &amp;quot;&amp;quot;

The declared package "com.how2java.j2se" does not match the expected package "" I encountered this error, because the first written document, after loading the server caused it, de...

Java method quot

Table of contents 1. Method quot 2. Method quoting symbol Third, the instance method of the reference object Fourth, instance method of reference class Fifth, reference the constructor 1. Method quot ...

The applet quot Vant weapp

Official website introduction: https://vant-contrib.gitee.io/vant-weapp/quickstart Be sure to follow the steps! Intersection 1. Install NPM package Perform the command to install the NPM package in th...

The second development control and quot

Direction of first, secondary development 1.1 Add class library 1.2 Add components in the class library 1.3 Add Form to reference and inherit the Text 1.4 Add a ErrorProvider control Write custom logi...

More Recommendation

6. Method quot

6. Method quot When we use Lambda, if there is only one method in the method, there is only one method (including the constructed method), and we can use the method to reference to further simplify th...

Hide custom view button to lock list view

Scenario: A role can only see some information in the customer list, and assign a list view of the customer to this role, and it is not allowed to modify this view. Solution: Hide custom view button s...

list of related practice exercises

Comma code Assume the following list: spam = ['apples', 'bananas', 'tofu', 'cats'] Write a function that takes a list value as a parameter and feeds back a string. The string contains all the elements...

Salesforce related presentations

Salesforce related presentations Salesforce word, gradually warming up in the country in recent years, especially this year, Salesforce acquired Tableau and its cooperation with Ali cloud of two thing...

The practice of SOAP in Salesforce

This SOAP related article isSalesforce development tutorial (3)I have learned that many students will encounter various problems in system integration. I wrote an article about REST before.Use Postman...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top