function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vandy7Vandy7 

Navigating to visualforce page

Hai everyone,

 

 

 

 

 

 

 

Can anyone suggest me a method to navigate to a visualforce page onclick of a custom button in force.com.

I am using a javascript function to navigate but the page opens in a new window.But I want it to be opened in the same window.

 

Thanks in advance.

 

imuino2imuino2

 

<apex:outputLink value="https://www.salesforce.com" id="theLink">www.salesforce.com</apex:outputLink>

Use apex:outputLink, if you want it to open in the same window the target attribute:

Possible values for this attribute include "_blank", "_parent", "_self", and "_top". These are the possible values, use self to open it on the same window.

Vandy7Vandy7

Thanks for the reply.

 

But I dont want to navigate from a button on visualforce page.The button what I have specified is a custom view button created in Contact(Customize-Contacts-Buttons and links- Custom button) page.So I need a Javascript function to do that.

 

Please help me with this.

Shailesh DeshpandeShailesh Deshpande

you dont need a javascript function for that purpose. it can be acheived in following manner...

 

setup-->customize--->contacts --> buttons and links ---> your button -- > edit

 

and then

 

1)Set the Display Type to List Button/Detail Page Button.
2) Set the Content Source to Visualforce Page.
3)From the Content drop-down list, select the page on which you want to go.
4) Click Save.
5) A warning will display notifying you that the button will not be displayed until you have updated page layouts. Click OK.

gv007gv007

At the time of button creating there is list box option,

 

Behavior

 

it have the options like this

1.want display existing window

2.new window

 like that so select that it will work with out any script.

 

 

or If u have any specific case (getting some [parameter)

 

Thanks

Gopi

Vandy7Vandy7
Thanks for the reply. But I am not working in that scenario. I am validating the current page and want to move to another page if the function works(if-else condition). So,I need to make use of javascript function. Please help me.
yvk431yvk431

did you tried this

 

window,location.href = '/apex/VFP';

incuGuSincuGuS

Use

 

 

if(doValidation())
window.location.href = '/apex/yourPage';
}
else {
alert('show error, or whatever you do');
}

function doValidation(){
// whatever.
}

 

 

 Is this what you wanted?

 

Vandy7Vandy7

Thank for your reply.I am able to navigate to some other page now through the javascript.

 

But now am facing a problem. Initially,I will be selecting some contacts(through checkboxes) from CONTACT tab and will click on a button(list button for CONTACT)

 

 

Below is the Javascript code what I have used for the button.

 

{!REQUIRESCRIPT("/soap/ajax/8.0/connection.js")}

var records = {!GETRECORDIDS($ObjectType.Contact)};

if (records[0] == null)
{
alert("Please select at least one contact");
}
else
{
window.location.href= '/apex/bulkVF';
}

Now,on navigating to other page(bulkVF) I want the selected contacts to be filled in pageBlockTable of bulkVF. But it is displaying only the page with no selected contacts in the table.

 

Earlier,when I linked that page directly to the button(Content type-Visualforce Page),I was able to get the contacts  filled in pageBlockTable of bulkVF.

 

Please help me.