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
Cristian TrifCristian Trif 

Custom Button on Visualforce page that will create a new task when clicked

Hi, I want to create a custom button that creates a new task in my visualforce page. It's identical with this 'New' Button from Home Object - My Tasks.

User-added image

I implemented my button in VF like this:
 
<apex:pageBlockButtons location="top">
 <apex:commandLink value="New Task"   styleClass="btn" style = "text-decoration:none" />
</apex:pageBlockButtons>

And now the only thing to do is when i press this New Task button to redirect me to this page. Which is for creating New Task basically.

User-added image
Best Answer chosen by Cristian Trif
Cristian TrifCristian Trif
<apex:pageBlockButtons location="top">
                 <apex:outputLink value="{!URLFOR(($Action.Task.NewTask))}" target="_blank" styleClass="btn"> New </apex:outputLink><br/><br/>
</apex:pageBlockButtons>

This fixed it.