1). I am not able to understand why is this exception coming in JavaScript. I am doing like below -

// Service Side Code
Calculator__c Calculator= [Select id, name, (select id, 
fee_amount__c, cost_Amount__c, Type__c, from
Cost_Details__r) From Calculator__c p where id =: PId];

var ids = {!Calculator.Cost_Details__r};


Here server returns [a39Q0000000CvnaIAC, a39Q0000000Cx5OIAS, a39Q0000000CvnfIAC] string which in am assigning into ids variable.

alert is not coming up and when i goto error console i get -Uncaught ReferenceError : a39Q0000000CvnaIAC is not found JavaScript Exception.

2) I am calling a Java Script remote Function like below -

        function getPlanDetails() { 
            var str = "";
                function(result, event){
                    if (event.status) {                     
                        for(var i=0; i<result.length ; i++){
                            str += result[i].id;
                            str += ", ";
                            str += result[i].Cost_Amount_f__c;
                    } else if (event.type === 'exception') {

                    } else {


Alert is showing "Undefined, 1000" Why Id is not being displayed in alert if my server side function returning both ID and Cost_Amount_f__c?

  • Whats the returns type in your visualforce remoting function?Can you get us the Apex controller so that we can tell exact error – Mohith Shrivastava Jul 29 '13 at 13:53


[a39Q0000000CvnaIAC, a39Q0000000Cx5OIAS, a39Q0000000CvnfIAC] 

is not an array of strings, it's assuming they are objects which of course they are not (hence a39Q0000000CvnaIAC is not found error) . To be an array of strings, I think it would have to be

["a39Q0000000CvnaIAC", "a39Q0000000Cx5OIAS", "a39Q0000000CvnfIAC"]

As for your second point, since Javascript is case sensitive, could it be that the platform is changing the case of your returned list values from your selected id to Id and it isn't recognising id. Try changing:

str += result[i].id;


str += result[i].Id;
  • Then how can i resolve this error? and Why id is not being displayed in second example? can you please explain – Pramod Kumar Jul 29 '13 at 13:49
  • Can we see your server side code? – Phil Hawthorn Jul 29 '13 at 13:57
  • I have edited my question and added service side query – Pramod Kumar Jul 29 '13 at 14:00
  • @PramodKumar i've updated my answer – Phil Hawthorn Jul 29 '13 at 22:20

I am not sure in following one

for(var i=0; i<result.length ; i++){
                        str += result[i].id;
                        str += ", ";
                        str += result[i].Cost_Amount_f__c;

instead of iterating and adding to string, we can use the following one

var str = JSON.stringify(result);

will return json string of the result

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.