You need to sign in to do that
Don't have an account?
etechcareers
How to re-create the Task page in VF with whoid and whatid filled in??? Help please
Hi:
I want to re-create the Task Page in Visualforce and have the Whoid and what id filled in. Now, I can get this to work if I dont use the VF task page and use the standard task page. But I can not get it to work on the VF Page??/
Basically a user will click new task and it will open up this VF task page and have the whoid and whatid filled in automatically through URL. Do not know how to:
public PageReference Monitor(){ moni = new List<History__c>( [SELECT id, Student__c FROM History__c where Student__c=:ApexPages.currentPage().getParameters().get('oppIdd') AND id=:ApexPages.currentPage().getParameters().get('oppIddc') ]); //PageReference newpage = new PageReference('/00T/e?who_id=' + monitorstudent[0].Student__c+ '&what_id=' + monitorstudent[0].Id + '&retURL=%2Fhome%2Fhome.jsp'); PageReference newpage = new PageReference('/apex/Task?who_id=' + monitorstudent[0].Student__c+ '&what_id=' + monitorstudent[0].Id ); newpage.setRedirect(true); return newpage; } <apex:page standardController="Task" sidebar="false"> <apex:form > <apex:pageBlock title="Edit Task" id="thePageBlock" mode="edit"> <apex:pageMessages /> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> <apex:actionRegion > <apex:pageBlockSection title="Basic Information" columns="1"> <apex:inputField value="{!Task.Ownerid}"/> <apex:pageBlockSectionItem > <apex:outputLabel value="Subject"/> <apex:inputField value="{!Task.Subject}"/> </apex:pageBlockSectionItem> <apex:inputField value="{!Task.whoid}"/> <apex:inputField value="{!Task.whatid}"/> </apex:pageBlockSection> </apex:actionRegion> </apex:pageBlock> </apex:form> </apex:page>
Please help me figure this out. Thanks
ETechCareers
Here it goes....
<apex:page standardController="Task" sidebar="false" extensions="extensionsEx">
<apex:form >
<apex:pageBlock title="Edit Task" id="thePageBlock" mode="edit">
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:actionRegion >
<apex:pageBlockSection title="Basic Information" columns="1">
<apex:inputField value="{!Task.Ownerid}"/>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Subject"/>
<apex:inputField value="{!Task.Subject}"/>
</apex:pageBlockSectionItem>
<apex:inputField value="{!Task.whoid}"/>
<apex:inputField value="{!Task.whatid}"/>
</apex:pageBlockSection>
</apex:actionRegion>
</apex:pageBlock>
</apex:form>
</apex:page>
class:
public with sharing class extensionEx{
Task task = new Task();
public extensionEx(ApexPages.StandardController controller) {
this.task = (Task)controller.getRecord();
string strWhatId = System.currentPage().getParameters().get('oppIdd');
string strOwnerId = System.currentPage().getParameters().get('ownerId');
Task.WhatId = strWhatId ;
Task.OwnerId = strOwnerId ;
}
}
Cheers :)
All Answers
Here it goes....
<apex:page standardController="Task" sidebar="false" extensions="extensionsEx">
<apex:form >
<apex:pageBlock title="Edit Task" id="thePageBlock" mode="edit">
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:actionRegion >
<apex:pageBlockSection title="Basic Information" columns="1">
<apex:inputField value="{!Task.Ownerid}"/>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Subject"/>
<apex:inputField value="{!Task.Subject}"/>
</apex:pageBlockSectionItem>
<apex:inputField value="{!Task.whoid}"/>
<apex:inputField value="{!Task.whatid}"/>
</apex:pageBlockSection>
</apex:actionRegion>
</apex:pageBlock>
</apex:form>
</apex:page>
class:
public with sharing class extensionEx{
Task task = new Task();
public extensionEx(ApexPages.StandardController controller) {
this.task = (Task)controller.getRecord();
string strWhatId = System.currentPage().getParameters().get('oppIdd');
string strOwnerId = System.currentPage().getParameters().get('ownerId');
Task.WhatId = strWhatId ;
Task.OwnerId = strOwnerId ;
}
}
Cheers :)
THANK THANK THANK YOUUUU SOOO MUCH... You are awesome...
Hi srinivas,
For some reason your code does not compile in my org.
What its saying is in the constructor of the controller extension,
Error: Compile Error: Method does not exist or incorrect signature: System.CurrentPage() at line 7 column 26.
I replaced the System.Currentpage() with ApexPages.Currentpage() and it got compiled and saved.
But when i execute the Vf by passing an Id (Task ID) it raises run time exception and does not populate it with owner id.
Am i doing anything wrong. I am trying to learn, but got stuck out here.
Any help/idea on this is highly appreciated.
Thanks,
Sales4ce
is it possible for you to post the code?
Hi Srinivas,
Thanks for your help!.
Here is the code:
Here is the VF Page:
Thanks,
Sales4ce
were u able to fix the error?
iam trying to create the class for re-create the task page but i got compile error at
"string strWhatId = System.currentPage().getParameters().get('oppIdd');
string strOwnerId = System.currentPage().getParameters().get('ownerId');
....so please send me how to solve that error....
@Sales4ce has a good example above