+ Start a Discussion

Hyperlink onclick javascript console Problem

Hi ,


I am having an issue with javascript in Console. which is working fine in out of  console.  below is my code. i am not sure how to pass parameteres in console.

{srcUp('https://imagenow.com/webnow/index.jsp?action=document&folder= {!SUBSTITUTE( Contact.emplid__c , " ", "+") }'); 
} else { 
window.open('https://imagenow.com/webnow/index.jsp?action=document&folder= {!SUBSTITUTE( Contact.emplid__c , " ", "+") }'); 


Any help would be appriciated.


I'm going to suggest you check your single and double quotes, it looks like you start with a double and end with a single? 


This kind of stuff is always troublesome, if its not the problem above it could be other issues with escaping strings... 

Brian Lewis-JonesBrian Lewis-Jones
BeatofHeart, did you ever figure this out? I'm trying to do something similar - popping a JS alert when a hyperlink is clicked - but whenever I add fields to my alert string, it bombs out. (Works fine otherwise.) I've checked my quotes and things looked right...

Something like this:

HYPERLINK("javascript:alert('Margin: '&Margin__c&'\Margin 2: '&Margin_2__c&'\nPercentile: '&Percentile__c);",'Click for info' , '_blank')

Works fine if you take out the custom fields. I feel like JS can't access the custom fields in the hyperlink. Maybe that's because we need to define the object in JS so the code knows where to pull the fields from?

(...may have just given myself an idea here...)
Brian Lewis-JonesBrian Lewis-Jones
Got it! When using HYPERLINK to call JS, you need to introduce custom fields outside of the JS script (escape with double quote), and stringify them to be included.

HYPERLINK("javascript:alert('Margin: "&Text(Margin__c)&"\Margin 2: "&Text(Margin_2__c)&"\nPercentile: "&Text(Percentile__c)&"');",'Click for info' , '_blank')

Hope this helps somebody in the future! VERY helpful for calling JS out of a list view, where you don't want to select multiple records and instead see details for only one record with one click.