You need to sign in to do that
Don't have an account?
Adam Marks
Pass WhoId to Visualforce Task
So I figured this would be pretty simple but so far the answer has eluded me. Basically I created a VF page for a very specific Task type that is a Question/Answer format. This page will only ever be launched from a Lead through a custom button but I cannot for the life of me determine how to populate the WhoId automatically. I found this solution (https://developer.salesforce.com/forums?id=906F0000000960aIAA) but I think it's missing something because it did not work for me. Hopefully it's a relatively easy solution, seems like it would be.
This is my VF code (don't laugh)
This is the Extension, which I know is wrong.
This is my VF code (don't laugh)
<apex:page StandardController="Task" extensions="LeadQuestionnaireController"> <apex:form > <apex:pageBlock title="Lead Questionnaire" mode="edit"> <apex:pageblockbuttons > <apex:commandButton action="{!save}" value="Save"/> <apex:commandButton action="{!cancel}" value="Cancel"/> </apex:pageblockbuttons> <apex:pageblocksection > <apex:inputfield value="{!Task.WhoId}"/> </apex:pageblocksection> <apex:pageBlockSection title="Please answer questions below" Columns="2"> <apex:outputText value="1. Do you make the final decision when it comes to selecting a carrier for your upcoming shipment to XYZ event?"> </apex:outputText> <apex:inputField label=" " value="{!Task.A1__c}"/> <apex:outputText value="2. Do you typically ship more than 300 lbs to this event? Or will be planning to ship this amount in the event this is their first time to the show."> </apex:outputText> <apex:inputField label=" " value="{!Task.A2__c}"/> <apex:outputText value="3. How do you decide or what criteria do you use to choose a shipping service to handle your show shipments?"> </apex:outputText> <apex:inputField label=" " value="{!Task.A3__c}" style="width: 300px; height: 40px;"/> <apex:outputText value="4. Would you have any interest in considering our service for this upcoming event?"> </apex:outputText> <apex:inputField label=" " value="{!Task.A4__c}"/> <apex:outputText value="5. How many shows over a year do you typically ship to?"> </apex:outputText> <apex:inputField label=" " value="{!Task.A5__c}"/> <apex:outputText value="6. If not interested at this time, when do you typically evaluate your carriers?"> </apex:outputText> <apex:inputField label=" " value="{!Task.A6__c}" style="width: 300px; height: 40px;"/> </apex:pageblocksection> <apex:pageBlockSection title="Comments" Columns="1"> <apex:inputtextarea label=" " value="{!Task.Description}" style="width: 500px; height: 150px;"/> </apex:pageblocksection> </apex:pageBlock> </apex:form> </apex:page>
This is the Extension, which I know is wrong.
public with sharing class LeadQuestionnaireController{ Task task = new Task(); public LeadQuestionnaireController(ApexPages.StandardController controller) { this.task = (Task)controller.getRecord(); string strWhatId = ApexPages.currentPage().getParameters().get('oppIdd'); string strOwnerId = ApexPages.currentPage().getParameters().get('ownerId'); Task.WhatId = strWhatId ; Task.OwnerId = strOwnerId ; } }Thanks in advance.
I believe (given what you've posted here) that you want something like this for your extesion:
Key here is line 3, which creates a public property on the controller with a get method and a private set method. (you may find you want it as a public set method). This will give you a merge obj on your VF page for {!task.whoId}.
Additionally, as i understand it, it since this is an extension on lead, the who ID will be the ID of the lead you're working with. Hence the call to getId on the main controller variable.