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
vivek kasiviswanathanvivek kasiviswanathan 

How can I add a hyperlink to support normal and console view with hyperlink Javascript disabled

Hi, Javascript is blocked in hyperlink with Spring 2017. The problem I have is with an existing link that works for both normal and cosole view. Now, i'm not allowed to check for typeof(ScrUp); I'm not able solve this problem by creating an empty Visualforce page and an Apex controller followed by pass the required values from the link to controller, execute the logic to decide the URL in controller method and perform the redirect. The problem is that the new vf page itself opens in a new tab like a new window in both normal and console view. Please share your inputs on how I can fix this. Thanks
Mohammad Asim AliMohammad Asim Ali
is the HYPERLINK in a formula field? I created a HYPERLINK in formula field with the srcUp last week and it seems to work fine.

HYPERLINK("javascript:if(typeof(srcSelf)=='function'){srcSelf('/apex/pageName?isdtp=vw&Id="&Id&"');}"+"else{window.location.href='/apex/pageName?Id="&Id&"'}", "Friendly Name", "_target")
vivek kasiviswanathanvivek kasiviswanathan
Not sure. How that worked for you. Please see
Mohammad Asim AliMohammad Asim Ali
Thanks for the documentation. The below is from the link you posted - 
What action do I need to take?
Although JavaScript in hyperlink formula fields will continue to execute after the Spring ‘17 release, Salesforce recommends that admins begin reviewing their use of JavaScript in hyperlink formula fields and migrate to alternative solutions.

So it means it will still work at least till Winter '18 release and that's why it worked for me. However, I have to find an alternative solution soon. I'll keep you posted as soon as I find something.
Please update this thread if you find anything too.
Mohammad Asim AliMohammad Asim Ali
So i tried the alternative solution to just use the hyperlink as a normal hyperlink without any javascript and it seems to work like a charm. No need to use srcUp or srcSelf.
HYPERLINK("/apex/pageName?isdtp=vw&Id="&Id, "friendly name", "_target").
I had to open the visualforce in the same tab, so used "_self".

This too works perfectly. Seems like we don't need the typeof(srcUp) function any more.

Note - Ensure that the url in the hyperlink has 'isdtp=vw'. This is required for the system to recognize that it is in console. Outside the console, it will try to remove the header, even if showHeader is marked as true in the visualforce page.