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
bauembauem 

Custom field with onClick javascript?

Hello all

 

I try to make a custom field in contact that can execute some JavaScript code when it is clicked to realize a click to dial phone number field.

 

With a custom field in contacts with the following formula I could already invoke JavaScript but this also opens a new empty window:HYPERLINK("javascript:alert('I should dial to  " & Phone & "  now')", Phone)

HYPERLINK("javascript:alert('I should dial to  " & Phone & "  now')", Phone)

 Is there a way doing that without opening a new window?

 

In HTML it should look for example like this:

<a href="DialTo:(111)222-3333" onClick="alert('I should dial to (111)222-3333');return false;">(111)222-3333</a>

 

 

Thank you for suggestions,

Matthias

Best Answer chosen by Admin (Salesforce Developers) 
Ispita_NavatarIspita_Navatar

Hi , 

Please try the following:-

HYPERLINK("javascript&colon;alert('I should dial to " & Phone & " now')", Phone, "_self")

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

All Answers

Ispita_NavatarIspita_Navatar

Hi , 

Please try the following:-

HYPERLINK("javascript&colon;alert('I should dial to " & Phone & " now')", Phone, "_self")

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

This was selected as the best answer
bauembauem

Yes, that works. Thank you for help.

 

I thought that I already tried that and then the alert box was opened in the same window but the original salesforce page behind of the alert box was replaced by a blank page. But now it works fine. Probably I did not exactly that before.