+ Start a Discussion

ID not found in Update call

I am trying to identify a certain record on a custom object and Flag it. The first part of my Scontrol identifies if any records exists already with the flag and if so, it removes the flag on that record. This is the section where something goes wrong...
var current_flagged_record = find_records.getArray('records');
for (var i=0; i<find_records.size; i++)
var remove_flag = new sforce.SObject('Funnel_Scorecard__c');
remove_flag.id = current_flagged_record[i].id;
remove_flag.Most_Recent__c = "false";

var save = sforce.connection.update([remove_flag]);
I am able to find the record and the ID - if I 'alert' it i can see it is in 'current_flagged_record'. However in the update call the the ID in "current_flagged_record[i].id" is undefined for some reason. If I hardcode the Unique ID in the update call everything works perfectly, but dynamically something is not working.
Any ideas?

Greg HGreg H
In your FOR loop you are looping through the wrong array.  Use "current_flagged_record.size" instead of what your using now.

Thanks for the response Greg.

However, when I change the array to loop through, it does not seem as if the loop triggers at all. I get no error messages, but the 'alert' i have inside the loop does not trigger.

Any suggestions?



Actually, problem solved... I had to change the line where I get the unique ID to update from:

remove_flag.id = current_flagged_record[i].id;


remove_flag.id = current_flagged_record[i].get("Id");