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
Matan AlonMatan Alon 

Hide delete button base on task subject value

I'm trying to figure how to hide the delete button in the task detail page when the subject field value equal to 'xxxx' and the profile not equal to admin.
I know i need to custom the delete button with a Visualforce Page but i dont have any clue on how the script needs to look like.

Please help me with that,
Thanks in advance,
RamuRamu (Salesforce Developers) 
The below articles might help
Matan AlonMatan Alon
Thanks for the links.
I tried to use them but i dont know how to custom them to my needs.
Any help we be appreciated.
Vishal NegandhiVishal Negandhi
Or you can add a small rule in trigger which will not allow deletion of a record.

something like:

trigger prevendTaskDelete on Task(before delete){
     for(Task t :{
          if(check your conditions){
               t.fieldName.addError('You cannot delete this record');
Matan AlonMatan Alon
Thanks, but i've already created a trigger like that - i'm looking for a more elegant way to do that.