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

Onclick Javascript Button on Task

I have a button on the task object that closes the task by clicking the button intead of having to edit the task, change the status to Completed and save the task.  However, I would like to validate who is closing the task based on the current user and owner of the task.  So, does anyone know a way to compare the Current User to the Task.OwnerId?  I know how to structure it based on the result using an IF statement, but can't seem to find the right comparison.


I have tried to do...

If(Task.OwnerId <> "{!User.Id}"){
 alert("You have insufficient privileges to change this task.")
 perform function...

 I have tried different permutations of the "not equal" and still can't get past this point.


Additional note...if someone doesn't have the abillity to change the task, the system won't let them make the change.  However, it does refresh the screen like something did happen, but it doesn't close the task.  I would just like to be able to notify them of the issue when it happens.  Similar to when someone goes to edit the task that doesn't have permission they get the Insufficient Priviliges message.