You need to sign in to do that
Don't have an account?
JSENCODE incorrect argument type
I am trying to use JSENCODE to get away from stored XSS security flags. When I use it I get an error "Incorrect argument type for function 'JSENCODE()'"
I am not sure what I am getting wront on this. When I don't use JSENCODE the value comes out but when I wrap it in JSENCODE it gives the error when saving in Eclipse. Below is my code snippet, thanks for the help in advance.
function initialize() {
var myOptions = {
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: false
}
var locLat = {!JSENCODE(Location__c.Latitude__c)};
var locLong = {!Location__c.Longitude__c};
var myLatlng = new google.maps.LatLng(locLat, locLong);
var infowindow = new google.maps.InfoWindow({
content: "<b>{!HTMLENCODE(Location__c.Name)}</b><br>" + locLat + "<br>" + locLong
});
yes, jsencode requires a text parameter. So convert with the text function:
JSENCODE(TEXT(Location__c.Latitude__c))
All Answers
Please check the value you are passing i.e. what value is being stored in the Location__c.Latitude__c field for the record getting processed. It seems it is incorrect value.
Thanks for the response Kamal.
There are values in Latitude__c and Longitude__c, if I don't use JSENCODE the value shows as expected. I'm wondering if it is the type of value. These are defined as Number(3, 13), do I need to convert them into text for JSENCODE to work?
yes, jsencode requires a text parameter. So convert with the text function:
JSENCODE(TEXT(Location__c.Latitude__c))
Thank you, using TEXT function worked.
also thanks for tolerating a NEWB question.