2

I have a custom object and records of these objects can be submitted for approval via the standard approval process.

I have a custom Visualforce page for overriding the standard view action, so that a user friendly message appears if a particular condition is met.

The Visualforce page is below:

<apex:page standardcontroller="Custom_Object_A__c">
<apex:messages />
    <apex:sectionheader title="{!$ObjectType.Custom_Object_A__c.label} Detail" subtitle="{!Custom_Object_A__c.Name}"/>
    <apex:form >
        <apex:pageblock mode="maindetail" title="{!$ObjectType.Custom_Object_A__c.label} Detail">
        <apex:pageMessage escape="false" detail="Please note: this record <b>must have at least 1 attachment added against it in order to successfully submit it for approval</b>. If you try to submit for approval when there is not at least 1 attachment added, then you will receive an error and will be forced to return to the page." severity="info" strength="3"
        rendered="{!ISBLANK(Custom_Object_A__c.of_Attachments__c) || Custom_Object_A__c.of_Attachments__c < 1}"/>
            <apex:pageblockbuttons >
                <apex:commandbutton value="Edit" action="{!Edit}"/>
                <apex:commandbutton value="Delete" action="{!Delete}"/>


            </apex:pageblockbuttons>


            <apex:outputpanel >
                <apex:pageblocksection title="Information" showheader="false" collapsible="false" columns="2">
                    <apex:outputfield value="{!Custom_Object_A__c.Name}"/>
                    <apex:outputfield value="{!Custom_Object_A__c.Status__c}"/>
                    <apex:pageblocksectionitem />
                    <apex:pageblocksectionitem >
                        <apex:outputlabel value="Owner"/>
                            <apex:outputpanel >
                            <apex:outputfield value="{!Custom_Object_A__c.OwnerId}"/>
                        </apex:outputpanel>
                    </apex:pageblocksectionitem>
                    <apex:pageblocksectionitem />
                    <apex:outputfield value="{!Custom_Object_A__c.of_Attachments__c}"/>
                </apex:pageblocksection>
                <apex:pageblocksection title="System Information" showheader="false" collapsible="false" columns="2">
                    <apex:pageblocksectionitem >
                        <apex:outputlabel value="Created By"/>
                        <apex:outputpanel >
                            <apex:outputfield value="{!Custom_Object_A__c.CreatedById}"/> 
                            <apex:outputfield value="{!Custom_Object_A__c.CreatedDate}"/>
                        </apex:outputpanel>
                    </apex:pageblocksectionitem>
                    <apex:pageblocksectionitem >
                        <apex:outputlabel value="Last Modified By"/>
                        <apex:outputpanel >
                            <apex:outputfield value="{!Custom_Object_A__c.LastModifiedById}"/>
                            <apex:outputfield value="{!Custom_Object_A__c.LastModifiedDate}"/>
                        </apex:outputpanel>
                    </apex:pageblocksectionitem>
                </apex:pageblocksection>
            </apex:outputpanel>
        </apex:pageblock>
    </apex:form>


    <apex:outputpanel >
        <apex:relatedlist list="CombinedAttachments" title="Notes & Attachments"/>
        <apex:relatedlist list="ProcessSteps" title="Approval History"/>
    </apex:outputpanel>

</apex:page>

When I select the 'Submit for Approval' button on this page, the below error is returned.

enter image description here

I looked at this link here, which seems to suggest that:

"This is an intentional change which has been made by Salesforce in Winter'16 release to remove security vulnerability".

and...

Staring Winter'16, you will not be able to use the Custom Buttons to call standard URL for Approval Process Submission (which is "/p/process/Submit?... ").

Questions:

  1. I am unsure why I am receiving these errors, as this is a standard button on a Visualforce page?
  2. I am unsure what the security vulnerabilities specifically were pre Winter '16 for using Custom Buttons to call standard URL for Approval Process, although I assume it is related to cross-site scripting vulnerability as per the Trailhead link here?
  3. What are my options to navigate around this? I simply want to keep my Visualforce page which displays the user friendly message and enables a user to submit for approval from the page.

1 Answer 1

1

Well I cannot answer all of your questions. But I can suggest you a solution. We can handle the approval processs in APEX. That is kind of overkill bu writing a controller/extension. But there are ways to do so.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_process_example.htm

2
  • OK - thank you. It's incredibly frustrating to go through all this effort merely to get some helpful messages on the screen. Jan 11, 2017 at 18:13
  • I completely understand man :) Hope they fix this in future release :) Jan 12, 2017 at 6:48

You must log in to answer this question.

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