Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Apex Code Development
- :
- Trying to get the Page view ID...
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Trying to get the Page view ID...
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-02-2013 12:42 PM - edited 01-02-2013 12:42 PM
Hi all,
I have to definitively count the number of times a rep has read his/her particular leads...
I got the code working great, but I seem to be missing the "Back to List: Leads" link and
it's causing me to lose some goodwill with the CSRs.
I basically have a lead page override that looks like:
<apex:page standardController="Lead" extensions="LeadPageLoadCode" action="{!loadEvent}">
<apex:form >
<apex:detail subject="{!Lead.Id}" relatedList="true" showchatter="true" inlineEdit="true" />
</apex:form>
</apex:page>
...And the LeadPageLoadCode is actually a bit of work, because I have to check if the lead is converted, owned by someone else, etc... but FWIW, here it is;
public with sharing class LeadPageLoadCode {
private final Lead Lead;
public LeadPageLoadCode (ApexPages.StandardController stdController){
System.debug('Entering Constructor...');
this.Lead = (Lead) stdController.getRecord();
}
public PageReference loadEvent() {
PageReference leadPage = new ApexPages.StandardController(Lead).view();
System.debug('Entering loadEvent...');
String strLeadId = this.Lead.Id;
Id myId = UserInfo.getUserId();
List<Lead> myLeads = [SELECT IsUnRead__c, OwnerId , IsConverted from Lead where Id = :strLeadId LIMIT 1];
if(myLeads[0].IsConverted == true) { // can't do anything....
System.debug('Redirecting to ViewConvertedLead');
leadPage = new PageReference ('/p/lead/ViewConvertedLead/d?id='+myLeads[0].Id);
return leadPage;
}
if(myLeads.size() != 0 ) { // we have work to do...
if(myLeads[0].IsUnRead__c == null) {myLeads[0].IsUnRead__c = 0;}
if( myLeads[0].OwnerId == myId) {
if(myLeads[0].IsUnRead__c <= 0) {
System.debug('Lead.IsUnRead = 0');
myLeads[0].IsUnRead__c += 1;
update myLeads;
leadPage.setRedirect(True);
}
else {
System.debug('Lead.IsUnRead: '+myLeads[0].IsUnRead__c);
leadPage = new PageReference ('/apex/LeadPageAnchor');
}
return leadPage;
}
else {
System.debug('Lead.IsUnRead: '+myLeads[0].IsUnRead__c);
leadPage = new PageReference ('/apex/LeadPageAnchor');
}
}
else { // This is not the lead owner - do nothing
System.DEBUG('This is not the lead owner - do nothing');
leadPage = new PageReference ('/apex/LeadPageAnchor');
}
return leadPage;
}
}
...I'm omittintg the "LeadPageAnchor" for brevity, but suffice it to say it's just the same thing as the anchor--- it just keeps the page from going into an infinite loop. Also, this code only counts to 1 - but I fixed that elsewhere....
My problem is The "Back to List: Leads" link disappears.
Is there a way I can build this? it doesn't seem like I can get access to the Lead Page View ID on the view button override.
Any help is greatly appreciated.
Thanks!
Re: Trying to get the Page view ID...
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-02-2013 01:46 PM
Hi,
It seems SFDC uses some javascript to generate this link.
If you want to implement similar feature you can do something like this :
<apex:outputLink value="/{!MyObject.Id}">Back to List</apex:outputLink>where
MyObject = Leadid or you can redirect to lead tab by specifying "/00Q/o" in value.
Thanks,
Rahul
Certified Developer, Advanced Developer, Administrator, Sales Cloud Consultant,Service Cloud Consultant
Re: Trying to get the Page view ID...
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-02-2013 02:06 PM
Hi Rahul,
{!MyObject.Id} is the ID of the object, not the pageview, unless I'm missing something.
It also looks like pageviews are meta-data, and not objects, so things are looking more and more complicated.
Basically, if I display a lead page view and the URL looks like this:
https://cs4.salesforce.com/00Q?fcf=00BP0000000Ugau
...I need the "00BP0000000Ugau" part to get back to the previous page.
Thanks,
Re: Trying to get the Page view ID...
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-03-2013 06:19 AM
by MyObject I mean a public varible defined & used in the controller class
Certified Developer, Advanced Developer, Administrator, Sales Cloud Consultant,Service Cloud Consultant
Re: Trying to get the Page view ID...
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-03-2013 08:43 AM - edited 01-03-2013 08:54 AM
Hi Rahul,
The only variable I have in my controller class is the lead.
When I put the line you suggested in my page (the apex:outputLink);
<!-- apex:page standardController="Lead" !-->
<apex:page standardController="Lead" extensions="KevinsPageLoadCode" action="{!loadEvent}">
<apex:form >
<apex:outputLink value="/{!Lead.Id}">Back to List</apex:outputLink >
<apex:detail subject="{!Lead.Id}" relatedList="true" showchatter="true" inlineEdit="true" />
</apex:form>
</apex:page>
...All that happens is the lead page is re-displayed --
I need to go back to the view of the leads. Sorry if I wasn't clear.
I think I need a way to capture the fcf=00BP0000000Ugau in the controller, but it doesn;t seem to be passed vhen using an apex:detail tag.
Re: Trying to get the Page view ID...
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-03-2013 10:02 AM
Hi Rahul,
Specifying "/00Q/o" in the commandlink, like
<apex:commandlink value="Back To Leads: " action="/00Q/o"/>
Gets me back to the home page of the views, and not the specific view the user was on.
Re: Trying to get the Page view ID...
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-04-2013 07:01 AM
Hi bro,
As per SFDC...this is how the link works..... The "Back To List" link takes you back to the last ListView, on the last unadultrated SalesForce page that you viewed, if and only if you navigated through a link on that list.
Doesn't matter where you go in SF after that, or if you navigate through other ListViews if they're on custom VisualForce pages. From that point fwd all "Back To List" links will point back to that last listview of theirs that you navigated through.
Basically it uses Javascript & cache values to redirect to the previos view. So with native Visualforce programming its not possible to implement the exac functionality.
So as I mentioned earlier you can redirect the user back to any fixed list view. e.g with "/00Q/o" it will redirect you to Leads TAB.
You may also vote on the following Idea : http://success.salesforce.com/ideaView?id=08730000
Certified Developer, Advanced Developer, Administrator, Sales Cloud Consultant,Service Cloud Consultant
Re: Trying to get the Page view ID...
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-04-2013 08:44 AM
Yeah, I read and voted and even commented on that idea too.
The deal is that I navigate to a lead from the lead view via a page that uses an <apex:detail> token, and the link is disappearing.
There is talk of an S control out there that does this, but I haven't been able to find it. If you can find any info I'd appreciate it.

