This is OnClick Javascript code invoked from a List Button on a related list UI.
var cid = '{!Case.Id}';
varQueryString = "select id,integration_status__c,Target_System__c from transaction__c where case__c ="+"\'"+cid+"\'";
varQueryResult = sforce.connection.query(varQueryString);
if(varQueryResult.size == 0)
{
alert('No Transaction Available to perform Validation');
}
if(varQueryResult.size > 1)
{
alert('More Than one Transactions are present. Please delete one of the transaction');
}
if(varQueryResult.size == 1)
{
alert('Invoking Validate Transaction');
var recs = varQueryResult.getArray("records");
alert(recs[0]); //LINE 1
var tid = recs[0].id; //LINE 2
alert(recs[0].id); // LINE 3
I am getting no output (a blank alert box to be more precise) at Line 3 but Line 1 displays a pop up box with the data elements.
Line 1 output :
{type:'Transaction__c', Id:'a3P11000000Ekc9EAC', Integration_Status__c:'Processing', Target_System__c:null, }
Line 3 : Blank alert pop up box..why ?
Can someone let me know why ?
alert(recs[0].Id)
. Though I would have expected the alert to display "undefined" if that was the problem.