You need to sign in to do that
Don't have an account?
NIK_USA
Visualforce Redirect in Javascript not working
Hi
I am trying to override a new Contact page and Record Type Page. It is working fine in SF1 mobile but in browser it is not doing anything. Here is the code. The result will return RT ID and it is working fine. The problem is redirecting in browser. Any Help is really appreciated.
Thanks
NIK
<apex:page tabStyle="Contact" standardController="Contact" extensions="ControllerNewContactRedirect" title="Select Record Type" action="{!redirectPage}" id="L1">
<apex:form id="L2">
<script type="text/javascript">
function validate() {
var vSelectedItem = (document.getElementById('L1:L2:L3:L4:L5:textRT')).selectedIndex;
var vFieldName = document.getElementById('L1:L2:L3:L4:L5:textRT').options[vSelectedItem].value;
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.ControllerNewContactRedirect.submitRecordType}',vFieldName,
function(result, event){
if (event.status) {
alert(result);
if( (typeof sforce != 'undefined') && (sforce != null) ) {
sforce.one.createRecord('Contact',result);
}
else{
window.location.href ='www.google.com';
//window.location.href ='apex/newCustomVFPage';
}
} else if (event.type === 'exception') {
alert(event.message);
} else {
alert(event.message);
}
}
);
}
</script>
<apex:pageblock id="L3">
<apex:pageBlockButtons >
<input type="button" value ="Submit" class="btn" onclick="validate();" />
</apex:pageBlockButtons>
<apex:pageBlockSection id="L4">
<apex:pageBlockSectionItem id="L5">
<apex:outputLabel value="Select Record Type" for="textRT"/>
<apex:selectList value="{!selectedRT}" id="textRT" size="1">
<apex:selectOptions value="{!RT}"/>
</apex:selectList>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
I am trying to override a new Contact page and Record Type Page. It is working fine in SF1 mobile but in browser it is not doing anything. Here is the code. The result will return RT ID and it is working fine. The problem is redirecting in browser. Any Help is really appreciated.
Thanks
NIK
<apex:page tabStyle="Contact" standardController="Contact" extensions="ControllerNewContactRedirect" title="Select Record Type" action="{!redirectPage}" id="L1">
<apex:form id="L2">
<script type="text/javascript">
function validate() {
var vSelectedItem = (document.getElementById('L1:L2:L3:L4:L5:textRT')).selectedIndex;
var vFieldName = document.getElementById('L1:L2:L3:L4:L5:textRT').options[vSelectedItem].value;
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.ControllerNewContactRedirect.submitRecordType}',vFieldName,
function(result, event){
if (event.status) {
alert(result);
if( (typeof sforce != 'undefined') && (sforce != null) ) {
sforce.one.createRecord('Contact',result);
}
else{
window.location.href ='www.google.com';
//window.location.href ='apex/newCustomVFPage';
}
} else if (event.type === 'exception') {
alert(event.message);
} else {
alert(event.message);
}
}
);
}
</script>
<apex:pageblock id="L3">
<apex:pageBlockButtons >
<input type="button" value ="Submit" class="btn" onclick="validate();" />
</apex:pageBlockButtons>
<apex:pageBlockSection id="L4">
<apex:pageBlockSectionItem id="L5">
<apex:outputLabel value="Select Record Type" for="textRT"/>
<apex:selectList value="{!selectedRT}" id="textRT" size="1">
<apex:selectOptions value="{!RT}"/>
</apex:selectList>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
Have you tried "window.open" ?