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
U JayU Jay 

How can get an alert on click a custom button indetail page of record if a condition met othervise lead to a new window.

How can get an alert on click a custom button indetail page of record if a condition met othervise lead to a new window.
Vatsal KothariVatsal Kothari
Hi,

You can do this by creating custom button which contains javascript code and add it to the page layout.
In javascript you can validate your condition.
For this go to Setup --> Objects --> (Your Object) --> ---> Buttons, Links, and Actions --> New Button or Links
Inside this Select Content Source as OnClick Javascript & Display type as Detail Page Button.
Then Write your validation condition, Save it.
Below is the example of javascript Validation :

if("{!User.Name}" == 'XYZ'){
  Alert('Hello XYZ');
}

After Saving add it to the Page Layout.

If this solves your problem, kindly mark it as the best answer.

Thanks,
Vatsal