You need to sign in to do that
Don't have an account?

Get Id from Console View?
Hello everyone,
We have a Visualforce page calling an Apex Class which currently obtains the record Id from the URL. We're attempting to implement Console and this process no longer works in Console View. I'm trying to understand how to replace the referheader with the getEnclosingPrimaryTabObjectId() function for Console, but I keep coming up short. Any advice would be appreciated! Here's the existing code:
We have a Visualforce page calling an Apex Class which currently obtains the record Id from the URL. We're attempting to implement Console and this process no longer works in Console View. I'm trying to understand how to replace the referheader with the getEnclosingPrimaryTabObjectId() function for Console, but I keep coming up short. Any advice would be appreciated! Here's the existing code:
public with sharing class TaskSidebarExtension { public Task tsk {get;set;} public String refer {get;set;} public Boolean valid {get;set;} public String parentId {get;set;} public String recordName {get;set;} public String phoneNumber {get;set;} public string redirectUrl {get;set;} public TaskSidebarExtension(ApexPages.standardController ctl) { this.tsk = (Task)ctl.getRecord(); } public void findRecord() { valid = true; try { //check the referer header (send via the iFrame) and extract the record id String referHeader = ApexPages.currentPage().getHeaders().get('referer'); if (referHeader != null) { refer = referHeader; } if (refer != null) { Integer startPos = refer.lastIndexOf('/')+1; Integer endPos = refer.indexOf('?'); if (endPos < 0) endPos = refer.length(); parentId = refer.substring(startPos,endPos); }
You should check it in your visualforce page that your page is opened in Classic or Console and then get the record id.
Hi @SalesFORCE_enFORCEr!
Thanks for the comment! I'm still confused because the Visualforce page is using the Apex class as an extension and pulling values from that like this: Since it's getting the values from the Apex Class {!phoneNumber}, etc. I was wondering if I could use the sforce.console.getEnclosingPrimaryTabObjectId function within the Class instead of on the Visualforce page? Here is my thought process:
However, I'm not sure where to reference the toolkit within the Apex Class... Am I way off track?