How can i create a "New" button on my VF page - salesforce

I am using custom object for my visualforce. How can i create a "New" button on my VF page so that it redirect me to the page where i can create my new record for that object ?

You can use {!URLFOR($Action.Custom_Object__c.New)} to get the URL.

Related

Return URL to redirect list view which is visualforce page

i have 1 custom object test_2__c and i created tab of it.
i have overridden this tab with a visual force page (tab redirect).
<apex:page action="{!URLFOR($Action.Test_2__c.List,$ObjectType.Test_2__c)}"/>
and i have 1 list button called "New". it is a button URL.
{!URLFOR($Action.Test_2__c.New)}?returnURL={/apex/tabredirect}
so when i click on this button from list view it opens an edit page for inserting a new record (The standard salesforce edit page, i didn't override it).
Now I am facing an issue here, when i click on "cancel" button from edit page, it remains on that page, i want to redirect it to list view which i have overridden with the visual force page.
Have you tried adding a cancelURL parameter to the URL? For example, you can send the user to a new visualforce page on cancel with the following parameter
...&cancelURL=/apex/YourApexPageNameHere

How to hide the VF page in Opportunity View in salesforce

i am using one Vf page in opportunity page and and have one checkbox above the VF page as
Approverd ---------- checkbox
....................................................Visual force page..........................................
Data
.............................................................................................................................
what i did is when check box is uncheked the vf page or view that show above is hide on save button click that work perfectly.but the blank space is there in the place of VF page .
I hope you got what I mean.
You can create 2 different opportunity page layouts. The first layout with your checkbox the second with the visualforce page. You assign the 2 page layouts to different RecordTypes. Your checkbox can trigger a workflow that is changing the record type and the pagelayout.
The next option is to use javascript to hide the section, but this is not reliable.

Get View on VF page

I want to get object view on a custom VF page.
eg: when we click on a object in salesforce we get a view i want that view on a VF page which i create.
Can anybody help me to solve this problem. If possible provide me the apex-code
Thanks
Anu
That view is called a detail page. There is in fact an visualforce component called apex:detail that does exactly what you want.

Print a datatable from VF page

I have two apex:datatable in my VF page. I need an option of printing these tables from the VF page. How as renderasPdf work? does it print the whole page or can we render only that datatable? Or should we have the table generated in another vf page and render that page as pdf
Any pointers?
Thanks
Prady
renderAs=pdf renders the entire page. You could make your datatable a custom component and include it in two different VF pages: 1 that is your screen-only page, the other that is a pdf VF page.

Can i call a vf page as popup from a custom link button from a standard sf page

I want to show a popup of list of cases without parentid and allow to select usign checkbox and the selected cases are added up in a related list. This popup would be availabe on clicking of link button
First question would be can i call a vf page as popup from a standard page? The rest i guess i can hande it in the VF page
Thanks
Prady
Yes, you create a link button for the object in whose page layout the link will reside. As a source for the link button choose "Visual force page" and choose a page. Keep in mind that the vf page MUST use standardController for the same object (with or without extensions) or it will not show up in the list. Choose to show the page in a new window and later place the link button on the page layout.

Resources