+ Start a Discussion
asdfgasdfg 

Visualforce List View

Hi Everyone,
                         I have been stuck at a point for a long time. Kindly help me out.

1. I have created a Apex Page (Tab) where I am Displaying all the Activities in a list view, Now, when i click on the Subject (Hyperlinked with Event Id), The Page URL still remains that of the Previous Page. I have created a Apex Detail page for "Event" where i need to use the Event Id for displaying Additional details. 

In the second Page "Event" I am using 
ApexPages.currentPage().getParameters().get('id') for capturing the Id of the Event. But this
is not working as the previous page never returned the Event Id in the URL.

Please Let me know, If from the List view, How i can get the Normal Salesforce Url as lik : http://salesforce.com/00UT0000001WcC9

Below are my Attached Code. Page Code -



Code:
<apex:page Controller="CallCode" tabstyle="Event">
<apex:form >
<apex:pageBlock Title="Activity/Event Management" mode="view">
<apex:pageBlockButtons location="Top">
<apex:selectList value="{!ActivityType}" size="1">
<apex:selectOptions value="{!items}"/>
</apex:selectList>
<apex:commandButton value="Create" action="{!Submit}"/><p/>
</apex:pageBlockButtons>
<apex:selectList id="CallsListView" value="{!ListCalls}" size="1" onChange="{!allcalls}">
<apex:selectOption itemValue="My Calls" itemLabel="My Activities / Events">
</apex:selectOption>
</apex:selectList>
<apex:outputPanel id="out">
<apex:actionstatus id="status" startText="Loading Calls....">
<apex:facet name="stop">
<apex:outputPanel >
<apex:pageBlockTable value="{!allcalls}" var="call">

<apex:column >
<apex:facet name="header"><strong>Subject</strong></apex:facet>
<apex:commandLink action="{!go}" rerender="form">
{!call.Subject}
<apex:param name="id" value="{!call.Id}"/>
</apex:commandLink>
</apex:column>

<apex:column value="{!call.whatid}"/>
<apex:column value="{!call.Id}"/>
<apex:column value="{!call.StartDateTime}"/>
<apex:column value="{!call.EndDateTime}"/>

</apex:pageBlockTable>
</apex:outputPanel>
</apex:facet>
</apex:actionstatus>
</apex:outputPanel>
</apex:pageblock>
</apex:form>
</apex:page>

 
ActivityTab
Code:
public class CallCode
{
public PageReference go()
{
PageReference pageRef = new PageReference('https://tapp0.salesforce.com/'+System.currentPageReference().getParameters().get('id'));
pageRef.setRedirect(true);
return pageRef;
}
Event[] callList;
public Event[] getAllCalls()
{
callList = [select id,subject,ActivityDate, whatid,ownerid,whoid, StartDateTime, EndDateTime, Region__c, Division__c from Event where OwnerId = :UserInfo.getUserId() order by Activitydate Desc Limit 10 ];
return callList;
}
String s;
public String getListCalls()
{
return s;
}
public void setListCalls(String s)
{
this.s = s;
}
String ActivityType = null;
public PageReference test()
{
return null;
}
public List<SelectOption> getItems()
{
List<SelectOption> options = new List<SelectOption>(); options.add(new
SelectOption('012T00000004QEt','Branch/Office Visits'));
options.add(new SelectOption('012T00000004QGV','Case Development Meetings'));
options.add(new SelectOption('012T00000004R6o','Client/Prospect Meeting'));
options.add(new SelectOption('012T00000004R6t','Day at the Firm'));
options.add(new SelectOption('012T00000004R6u','Desktop Application Plan Presentation'));
options.add(new SelectOption('012T00000004QEy','FA/PB visit'));
options.add(new SelectOption('012T00000004R6v','Meeting with Low Adopters'));
options.add(new SelectOption('012T00000004R6w','Planning Center Presentation'));
options.add(new SelectOption('012T00000004R6y','VIP Meeting'));
options.add(new SelectOption('012T00000004R73','Collaboration with Specialists'));
options.add(new SelectOption('012T00000004R6z','FPDA Account'));
options.add(new SelectOption('012T00000004R70','Recruit Meeting'));
options.add(new SelectOption('012T00000004R6p','Regional Activity'));
options.add(new SelectOption('012T00000004REY','Management Meeting'));
options.add(new SelectOption('012T00000004R74','Specialist Professional Development'));
options.add(new SelectOption('012T00000004R79','Specialist-lead Seminar/Training'));
return options;
}
public String getActivityType()
{
return ActivityType;
}
public PageReference submit()
{
String ActivityRecordType = ActivityType;
System.debug(ActivityRecordType);
PageReference pageRef = new PageReference('https://tapp0.salesforce.com/00U/e—retURL=/home/home.jsp&RecordType='+ActivityRecordType+'&cancelURL=/apex/Activity–sfdc.tabName=01rT0000000CqDx&sfdc.motif=Custom14&ent=Event');
return pageRef;
}
public void setActivityType(String ActivityType)
{
this.ActivityType= ActivityType;
}
}


Event Detail Page -

Code:
<apex:page standardController="Event" extensions="MyCustomEvent">
<apex:detail />
<apex:pageblock title="FA/PB Related List">
<apex:pageBlockTable value="{!FA_Branch}" var="Temp">
<apex:column value="{!Temp.FA_PB_Name__c}"></apex:column>
<apex:column value="{!Temp.FA_PB_Branch_Id__c}"></apex:column>
<apex:column value="{!Temp.FA_PB_Branch__c}"></apex:column>
<apex:column value="{!Temp.Name}"></apex:column>
</apex:pageBlockTable>
</apex:pageblock>

<apex:pageblock title="Branch Related List">
<apex:pageBlockTable value="{!Branch}" var="Temp1">
<apex:column value="{!Temp1.Branches__c}"></apex:column>
<apex:column value="{!Temp1.Branch_Division__c}"></apex:column>
<apex:column value="{!Temp1.Branch_Region__c}"></apex:column>
<apex:column value="{!Temp1.Name}"></apex:column>
</apex:pageBlockTable>
</apex:pageblock>

</apex:page>

 Event Controller -
Code:
public class MyCustomEvent 
{
public MyCustomEvent(ApexPages.StandardController controller)
{
}
FA_Branch__c[] MyFA_BranchId;
public FA_Branch__c[] getFA_Branch()
{
String WhatIds = ApexPages.currentPage().getParameters().get('whatid');
MyFA_BranchId = [select id,Name, Branch_Division__c, Branch_Region__c, FA_PB_Branch_Id__c, FA_PB_Branch__c, FA_PB_Name__c, Branches__c from FA_Branch__c where Branch__c = :ApexPages.currentPage().getParameters().get('id') and FA_PB_Name__c !=''];
return MyFA_BranchId;
}

FA_Branch__c[] My_BranchId;
public FA_Branch__c[] getBranch()
{
String WhatIds = ApexPages.currentPage().getParameters().get('whatid');
My_BranchId = [select id,Name, Branch_Division__c, Branch_Region__c, FA_PB_Branch_Id__c, FA_PB_Branch__c, Branches__c from FA_Branch__c where Branch__c = :ApexPages.currentPage().getParameters().get('id') and Branches__c !=''];
return My_BranchId;
}
}


Thank to you all in Advance....

Sanjay
 


Ron HessRon Hess
try this :

Code:
 public PageReference go()     {
   PageReference pageRef = new PageReference('/'+System.currentPageReference().getParameters().get('id'));
pageRef.getParamaters('id', System.currentPageReference().getParameters().get('id')  );
pageRef.setRedirect(true);
return pageRef;
}

 
two things,
one don't include the server url in your pageReference, it will be fine to have a relative path, and it will work after it's installed in production
second, by setting the ID on the page parameters()  explicitly you should be able to see it there on the next page you go to.

setting the ID may not be needed, it should appear in the Event controller extension , check in the constructor to see what it is:

where you have :
Code:
 public MyCustomEvent(ApexPages.StandardController controller) 
        {
        }

 
try to explore that controller object, see if the ID is available, it should be, if so store it in a global in that extension and reference it in the rest of that class.

Code:
 public MyCustomEvent(ApexPages.StandardController controller) 
 {
     Event ee = (event)Controller;
system.debug( ee.id );
 }