Try this it will help you <apex:page standardController="Contact" extensions="ContactRedirect">
<script type="text/javascript">
window.onload = function(){
alert('Gaurav');
document.getElementById("FormId").submit();
}
</script>
<html>
<body>
<form action="{!customPage}" target="_top" id="FormId">
</form>
</body>
</html>
</apex:page>
public class ContactRedirect {
public contact contact{get;set;}
public list<User> userList {get;set;}
String recordId;
public PageReference customPage{get;set;}
public ContactRedirect(ApexPages.StandardController controller) {
redirect();
}
public PageReference redirect() {
recordId = controller.getId();
system.debug('recordId'+recordId);
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;
}
}
error
Close
1 answer