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
orikkerorikker 

Overwrite Delete button on Task with custom Visualforce page.

Does anyone know how? there is no standard controller for Tasks...

Best Answer chosen by Admin (Salesforce Developers) 
Jeremy.NottinghJeremy.Nottingh

Put standardcontroller="Task" in the page tag.

 

Jeremy

All Answers

Jeremy.NottinghJeremy.Nottingh

There is a standard controller for Task. There's no standard set controller, but I don't think you would need that to override the Delete button.

 

Depending on what you want to do instead of Delete, though, you would probably need a controller extension. What should be the behavior of your page?

 

Jeremy

orikkerorikker

When user tries to delete task, it should check his profile - if it's admin then delete, otherwise warn that not allowed and send back to the record,

 

 

Here is the page that I have

<apex:page action="{! if ($Profile.Name != 'System Administrator',
null,
URLFOR($Action.Task.Delete, $CurrentPage.Parameters.id,[retURL='/007'],true))}">

    <apex:pageBlock >
        <apex:PageMessage summary="You are not allowed to Delete Tasks and Call Logs"
            severity="Warning"
            strength="3"/>
        <apex:pageMessages />

    </apex:pageBlock>
 
</apex:page>

 

Jeremy.NottinghJeremy.Nottingh

Your code works in my organization, what bad results are you getting?

 

Jeremy

orikkerorikker

It works for me too, but I can't use this page when I go to overwrite Delete button on Tasks... It just does not show up in the available visualforce pages... Any ideas how to make it show up there?

Jeremy.NottinghJeremy.Nottingh

Put standardcontroller="Task" in the page tag.

 

Jeremy

This was selected as the best answer
orikkerorikker

Ok. This is embarassing... I new I needed that tag but I did not know one existed for Tasks... Is that new for Summer 01 release?

jemmjemm

orikker,  did this end up working for you?  I need the same function and I am surprised it is so hard to do something so simple!

orikkerorikker

It was a while ago. What exactly are you trying to do? :)

jemmjemm

I'm trying to create a page to override the Delete button on the task page if anyone other than the administrator tries to delete that task.   I'm beginning to think that it's going to be impossible to have it work.   If you have any suggestions, they would be greatly appreciated!!  :)

orikkerorikker

It's your lucky day today :)

 

This should work.

 

<apex:page standardController="Task" action="{! if ($Profile.Name != 'System Administrator',
null,
URLFOR($Action.Task.Delete, $CurrentPage.Parameters.id,[retURL='/007'],true))}">

    <apex:pageBlock >
        <apex:PageMessage summary="You are not allowed to delete Tasks"
            severity="Warning"
            strength="3"/>
        <apex:pageMessages />

    </apex:pageBlock>
 
</apex:page>

 

jemmjemm

YOU ARE MY HERO!!! thank you so much

Vishal (Sops)Vishal (Sops)

Thanks guys for the code, but I need a bit further customization. My requirement is that a particular user named Vishal should only be able to delete tasks assigned to him. Here's my code.

 

<apex:page action="{

!if($User.Username ='vsharma@cvent.com.cvent',

    null,

    urlFor($Action.Task.Delete, $CurrentPage.Parameters.id, [retURL='/00T'], true)

    )

    )

    }"

  standardController="Task">

     <apex:pageBlock >

        <apex:PageMessage summary="You are not allowed to delete Tasks"

            severity="Warning"

            strength="3"/>

        <apex:pageMessages />

    </apex:pageBlock>

</apex:page>

 

I don't know where & how to embeed 2nd condition (tasks assigned to Vishal only). Can you guys help please.

 

Best Regards,

Vishal Sharma

Sagar LakhaniSagar Lakhani

Thanks For the Code....

Thanks,

Sagar Lakhani