You need to sign in to do that
Don't have an account?
Jyosi jyosi
Overriding the "New" button Functionality
Hello Everyone,
Based on userLogin i need to shift the page layout.
Here is what i am trying to develop When user login is xx Country i need to some them standard contact pagelayout.Else i need to some them custom pagelayout.
Below is code
<apex:page standardController="Contact" extensions="ContactRedirect" action="{!redirect}">
</apex:page>
Class
public class ContactRedirect {
public contact contact{get;set;}
public list<User> userList {get;set;}
String recordId;
PageReference customPage;
public ContactRedirect(ApexPages.StandardController controller) {
recordId = controller.getId();
system.debug('recordId'+recordId);
}
public PageReference redirect() {
Id selectedRecordType = ApexPages.currentPage().getParameters().get('RecordType');
User UserValue = [select Id,User_Country_Location__c from User where id = :UserInfo.getUserId()];
system.debug('UserValue!!'+UserValue);
if (UserValue.User_Country_Location__c=='XX')
{
customPage = Page.XXX;
customPage.setRedirect(true);
customPage.getParameters().put('id', recordId);
//return customPage;
} else {
customPage= /00Q/e?retURL=%2F00Q%2Fo&RecordType='+selectedRecordType+'&ent=Lead;
getParameters().put('nooverride','1');
}
return customPage;
}
}
When ever i click on new button it goes to the page
https://c.cs13.visual.force.com/apex/RedirectButton?retURL=%2F003%2Fo&RecordType=012500000009kEg&ent=Contact&save_new=1&sfdc.override=1
and immedistely it redircet to "https://cs13.salesforce.com/null"
Can you please help me what i am missing
Based on userLogin i need to shift the page layout.
Here is what i am trying to develop When user login is xx Country i need to some them standard contact pagelayout.Else i need to some them custom pagelayout.
Below is code
<apex:page standardController="Contact" extensions="ContactRedirect" action="{!redirect}">
</apex:page>
Class
public class ContactRedirect {
public contact contact{get;set;}
public list<User> userList {get;set;}
String recordId;
PageReference customPage;
public ContactRedirect(ApexPages.StandardController controller) {
recordId = controller.getId();
system.debug('recordId'+recordId);
}
public PageReference redirect() {
Id selectedRecordType = ApexPages.currentPage().getParameters().get('RecordType');
User UserValue = [select Id,User_Country_Location__c from User where id = :UserInfo.getUserId()];
system.debug('UserValue!!'+UserValue);
if (UserValue.User_Country_Location__c=='XX')
{
customPage = Page.XXX;
customPage.setRedirect(true);
customPage.getParameters().put('id', recordId);
//return customPage;
} else {
customPage= /00Q/e?retURL=%2F00Q%2Fo&RecordType='+selectedRecordType+'&ent=Lead;
getParameters().put('nooverride','1');
}
return customPage;
}
}
When ever i click on new button it goes to the page
https://c.cs13.visual.force.com/apex/RedirectButton?retURL=%2F003%2Fo&RecordType=012500000009kEg&ent=Contact&save_new=1&sfdc.override=1
and immedistely it redircet to "https://cs13.salesforce.com/null"
Can you please help me what i am missing
GauravTrivedi
Try this it will help you