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?

  • Can you edit the question and add what are you getting for alert(recType); and alert(records); ? – highfive Sep 4 '14 at 8:03
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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