Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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



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

share|improve this question
Can you edit the question and add what are you getting for alert(recType); and alert(records); ? – highfive Sep 4 '14 at 8:03
up vote 3 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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