1

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 Oct 13 '16 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 Oct 14 '16 at 12:52
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.

https://developer.salesforce.com/docs/atlas.en-us.salesforce_vpm_guide.meta/salesforce_vpm_guide/vpm_url_setvar.htm


The VF page

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

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();
        system.debug(pageParams);

        // 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 Oct 11 '16 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 Oct 12 '16 at 0:15
  • Ah, I see. I guess I need to do further testing. – Adrian Larson Oct 12 '16 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 Oct 12 '16 at 21:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.