0

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 ?

3
  • 2
    JavaScript is case sensitive. Try alert(recs[0].Id). Though I would have expected the alert to display "undefined" if that was the problem.
    – Keith C
    Commented Apr 11, 2014 at 9:57
  • Resolved my issue..How silly of me..tx keith :)
    – Varun
    Commented Apr 11, 2014 at 10:01
  • OK. I've posted that as an answer too so you can accept it using the tick to show the problem is solved.
    – Keith C
    Commented Apr 11, 2014 at 10:03

1 Answer 1

3

JavaScript is case sensitive. Try alert(recs[0].Id). Though I would have expected the alert to display "undefined" if that was the problem.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .