I am trying to create a custom "Log a phone call" button, the button will be displayed on the related list of Activities on an Account Record.

The button will use a Visual Force page as its source so that it can trigger a visual work flow.

The issue is I need to pass the AccountId of the parent Account that the related list is on as a parameter to the flow.

But when I select Visualforce page as the source it will only let me select the Visualforce page if it uses the standard Task controller.

How can I get the Account Id of the record I am on when I click the custom button on the related Activities list?

  • Why are you calling a VF page and not just the flow?
    – Fifedog
    Commented Oct 13, 2016 at 17:16
  • The page is being used just to make an elegant way to close the flow window. However for testing I removed all that and called the flow directly, please see my comment below.
    – ScottH7a9
    Commented Oct 14, 2016 at 12:52

1 Answer 1


Your VF page could use a StandardController for Activity and then your VF page's action attribute could execute a method which takes the id from the record and performs a redirect to the flow URL providing that ID as a parameter.

The VF page needs no markup in it other than the <apex:page standardController="Task" extension="yourClass" action="yourMethod" > since no content will be rendered by this page to the end user.

It's just acting as a router to create the URL to the flow and redirect the user.


The VF page

<apex:page StandardController="Task" extensions="activityRouter" action="{!routeToFlow}" >
  <!-- Begin Default Content REMOVE THIS -->
  This is your new Page
  <!-- End Default Content REMOVE THIS -->

The controller

public with sharing class activityRouter {

    public activityRouter(ApexPages.StandardController controller) {


    public PageReference routeToFlow() {

        // get the parameters from this page
        Map<String, String> pageParams = ApexPages.CurrentPage().getParameters();

        // create a new URL to the flow and append our params to it    
        return new PageReference('/someflowUrl?title=' + pageParams.get('title') + '&what_id=' + pageParams.get('what_id'));


Activity "Log a Call" button override

enter image description here

Resulting URL after clicking "Log a Call" button on an Account's Activity History related list https://domain.my.salesforce.com/someflowUrl?title=Call&what_id=001G00000229ESC

  • But don't you need to use StandardSetController in order to enable a List Button?
    – Adrian Larson
    Commented Oct 11, 2016 at 23:55
  • Log a Call isn't a list button, it's just a standard button on Activity that can be overridden.
    – Mark Pond
    Commented Oct 12, 2016 at 0:15
  • Ah, I see. I guess I need to do further testing.
    – Adrian Larson
    Commented Oct 12, 2016 at 0:30
  • I think this is on the right track, however now I have the incredibly odd error that I have asked about on this new question: salesforce.stackexchange.com/questions/144123/…
    – ScottH7a9
    Commented Oct 12, 2016 at 21:28

You must log in to answer this question.

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