Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.
{!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?

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

1 Answer 1

up vote 2 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

 
discard

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.