3
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}

var orderObj = new sforce.SObject("Order__c"); 

var recType = sforce.connection.query("SELECT name,Id from RecordType where developername = 'OR_Open'");
alert(recType);
var records = recType.getArray("records");
alert(records);
orderObj.RecordTypeId = records[0].Id;
alert(records[0].id);
sforce.connection.update([orderObj]);

window.location.reload();

}

I am getting undefined in alert(records[0].id);. Please suggest where am i wrong?

1
  • Can you edit the question and add what are you getting for alert(recType); and alert(records); ?
    – highfive
    Sep 4, 2014 at 8:03

1 Answer 1

3

Unlike Apex, JavaScript is case-sensitive so id is different to Id.

You need to use records[0].Id in your alert, rather than records[0].id.

You must log in to answer this question.

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