You need to sign in to do that
Don't have an account?
JBabu
URL redirection from VF page to standard case console page
Hi,
I want to redirect my VF page to std console case object and pre poulate few case fields.
I was able to redirect it, but I case is not getting displayed in console (it is getting displayed in normal case detail page)
I am loosing console std layout - mainly I need the suggested articles in right side section (it is missing).
Can some one please help me with this?
Here is my VF page:
<apex:page standardController="case" extensions="redirecttoconsoletest" title="{!Case.CaseNumber}" >
<apex:detail subject="{!Case.ID}" relatedlist="true" inlineEdit="true"/>
<apex:includeScript value="/support/console/28.0/integration.js"/>
<A HREF="#" onClick="testOpenPrimaryTab();return false">
Click here to open a new primary tab</A>
<script>
var button;
function disableButton()
{
button.disabled = true;
}
</script>
<script type="text/javascript">
function testOpenPrimaryTab() {
//Open a new primary tab with the salesforce.com home page in it
sforce.console.openPrimaryTab(null, 'http://www.salesforce.com', false,
'salesforce', openSuccess, 'salesforceTab');
}
var openSuccess = function openSuccess(result) {
//Report whether opening the new tab was successful
if (result.success == true) {
alert('Primary tab successfully opened');
} else {
alert('Primary tab cannot be opened');
}
};
function openNewCaseInSubTab() {
sforce.console.getEnclosingPrimaryTabId(openSubtab);
}
var openSubtab = function openSubtab(result) {
var primaryTabId = result.id;
var URLValue = "https://cs18.my.salesforce.com/ui/support/servicedesk/ServiceDeskPage#/"+{!NewCaseId}+"?isdtp=vw";
alert("Value of the URLValue......"+URLValue);
sforce.console.openSubtab(primaryTabId,'URLValue', true,'New Case', null, openSuccess, 'NewCaseSubtab');
};
var openSuccess = function openSuccess(result) {
if (result.success == true) {
alert('subtab successfully opened');
} else {
alert('subtab cannot be opened');
}
};
</script>
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:outputPanel id="DisplayEmployeeDetails">
<apex:outputLabel for="employeeDetails">Employee ID</apex:outputLabel>
<apex:inputText id="employeedetails" value="{!employeeid}" />
</apex:outputPanel>
<apex:commandButton value="Fetch Data..." action="{!fetchEmployeedetails}" />
</apex:pageBlockSection>
<apex:pageBlockSection >
<apex:pageBlockTable value="{!Employees}" var="employee">
<apex:column value="{!employee.Name}"/>
<apex:column value="{!employee.Employee_Title__c}"/>
<apex:column value="{!employee.Nick_Name__c}"/>
<apex:column value="{!employee.Primary_Phone__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock mode="maindetail">
<apex:commandButton action="{!newCase}" value="New Case" id="newCase" />
</apex:pageblock>
</apex:form>
</apex:page>
Apex class:
public class redirecttoconsoletest {
public List<Test_Employees__c> Employees {get;set;}
public string employeeid {get; set;}
public string newCaseId {get;set;}
public case emp;
public redirecttoconsoletest (ApexPages.StandardController stdController) {
// initialize the standard controller
this.emp = (Case)stdController.getRecord();
}
public pageReference fetchEmployeedetails() {
Employees = [select name, Email_Id__c, Employee_Title__c, Nick_Name__c, Primary_Phone__c from Test_Employees__c where name = :employeeid limit 1];
return null;
}
public pageReference newCase()
{
try {
List<Test_Employees__c> te = [select name, Email_Id__c, Employee_Title__c, Nick_Name__c, Primary_Phone__c from Test_Employees__c where name = :employeeid limit 1];
Case newCase = new Case (OwnerId = UserInfo.getUserId(), Status = 'New',
TeseCaseName__c = te[0].Email_Id__c, Test_Case_Preferred_ID__c = te[0].Primary_Phone__c);
insert newCase;
newCaseId = '/'+newCase.Id;
PageReference acctPage = new ApexPages.StandardController(newCase).view();
acctPage.setRedirect(true);
return acctPage;
} catch (Exception e) {
System.debug('*** Exception ***: ' + e);
}
return null;
}
}
Thanks,
JBabu.
I want to redirect my VF page to std console case object and pre poulate few case fields.
I was able to redirect it, but I case is not getting displayed in console (it is getting displayed in normal case detail page)
I am loosing console std layout - mainly I need the suggested articles in right side section (it is missing).
Can some one please help me with this?
Here is my VF page:
<apex:page standardController="case" extensions="redirecttoconsoletest" title="{!Case.CaseNumber}" >
<apex:detail subject="{!Case.ID}" relatedlist="true" inlineEdit="true"/>
<apex:includeScript value="/support/console/28.0/integration.js"/>
<A HREF="#" onClick="testOpenPrimaryTab();return false">
Click here to open a new primary tab</A>
<script>
var button;
function disableButton()
{
button.disabled = true;
}
</script>
<script type="text/javascript">
function testOpenPrimaryTab() {
//Open a new primary tab with the salesforce.com home page in it
sforce.console.openPrimaryTab(null, 'http://www.salesforce.com', false,
'salesforce', openSuccess, 'salesforceTab');
}
var openSuccess = function openSuccess(result) {
//Report whether opening the new tab was successful
if (result.success == true) {
alert('Primary tab successfully opened');
} else {
alert('Primary tab cannot be opened');
}
};
function openNewCaseInSubTab() {
sforce.console.getEnclosingPrimaryTabId(openSubtab);
}
var openSubtab = function openSubtab(result) {
var primaryTabId = result.id;
var URLValue = "https://cs18.my.salesforce.com/ui/support/servicedesk/ServiceDeskPage#/"+{!NewCaseId}+"?isdtp=vw";
alert("Value of the URLValue......"+URLValue);
sforce.console.openSubtab(primaryTabId,'URLValue', true,'New Case', null, openSuccess, 'NewCaseSubtab');
};
var openSuccess = function openSuccess(result) {
if (result.success == true) {
alert('subtab successfully opened');
} else {
alert('subtab cannot be opened');
}
};
</script>
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:outputPanel id="DisplayEmployeeDetails">
<apex:outputLabel for="employeeDetails">Employee ID</apex:outputLabel>
<apex:inputText id="employeedetails" value="{!employeeid}" />
</apex:outputPanel>
<apex:commandButton value="Fetch Data..." action="{!fetchEmployeedetails}" />
</apex:pageBlockSection>
<apex:pageBlockSection >
<apex:pageBlockTable value="{!Employees}" var="employee">
<apex:column value="{!employee.Name}"/>
<apex:column value="{!employee.Employee_Title__c}"/>
<apex:column value="{!employee.Nick_Name__c}"/>
<apex:column value="{!employee.Primary_Phone__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock mode="maindetail">
<apex:commandButton action="{!newCase}" value="New Case" id="newCase" />
</apex:pageblock>
</apex:form>
</apex:page>
Apex class:
public class redirecttoconsoletest {
public List<Test_Employees__c> Employees {get;set;}
public string employeeid {get; set;}
public string newCaseId {get;set;}
public case emp;
public redirecttoconsoletest (ApexPages.StandardController stdController) {
// initialize the standard controller
this.emp = (Case)stdController.getRecord();
}
public pageReference fetchEmployeedetails() {
Employees = [select name, Email_Id__c, Employee_Title__c, Nick_Name__c, Primary_Phone__c from Test_Employees__c where name = :employeeid limit 1];
return null;
}
public pageReference newCase()
{
try {
List<Test_Employees__c> te = [select name, Email_Id__c, Employee_Title__c, Nick_Name__c, Primary_Phone__c from Test_Employees__c where name = :employeeid limit 1];
Case newCase = new Case (OwnerId = UserInfo.getUserId(), Status = 'New',
TeseCaseName__c = te[0].Email_Id__c, Test_Case_Preferred_ID__c = te[0].Primary_Phone__c);
insert newCase;
newCaseId = '/'+newCase.Id;
PageReference acctPage = new ApexPages.StandardController(newCase).view();
acctPage.setRedirect(true);
return acctPage;
} catch (Exception e) {
System.debug('*** Exception ***: ' + e);
}
return null;
}
}
Thanks,
JBabu.