You need to sign in to do that
Don't have an account?
Uttirna Das
no such 'RecordType' on entity Account, How I can get recprdtypeid in javascript
{!REQUIRESCRIPT("/soap/ajax/37.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/37.0/apex.js")}
var accnt = new sforce.SObject("Account");
var recType=sforce.connection.query("SELECT name, id FROM RecordType" );
//alert(recType);
var records = recType.getArray("records");
//alert(records);
accnt.Name='{!My_Leads__c.Company__c}';
if(accnt.Name !="")
{
accnt.RecordTypeId = records[0].Id;
//alert(records[0].Id);
accnt.Id = '{!Account.Id}';
accnt.Name = prompt('','{!CLead__c.Company__c}');
accnt.OwnerId='{!CLead__c.OwnerId}';
var result = sforce.connection.create([accnt]);
if(result[0].getBoolean("success"))
{
alert('Account created successfully');
}
{!REQUIRESCRIPT("/soap/ajax/37.0/apex.js")}
var accnt = new sforce.SObject("Account");
var recType=sforce.connection.query("SELECT name, id FROM RecordType" );
//alert(recType);
var records = recType.getArray("records");
//alert(records);
accnt.Name='{!My_Leads__c.Company__c}';
if(accnt.Name !="")
{
accnt.RecordTypeId = records[0].Id;
//alert(records[0].Id);
accnt.Id = '{!Account.Id}';
accnt.Name = prompt('','{!CLead__c.Company__c}');
accnt.OwnerId='{!CLead__c.OwnerId}';
var result = sforce.connection.create([accnt]);
if(result[0].getBoolean("success"))
{
alert('Account created successfully');
}
Unlike Apex, JavaScript is case-sensitive so id is different to Id.
May I suggest you please give a try bu using Id in your SOQL query rather that id which should probably do the trick.
If you have something to fetch using javascript which is always in upper case then you can make use of toUpperCase() method which will always fetch the data after converting them into the upper case.
Please let us know if this helps.
Mark this as solved if it's resolved.
Thanks,
Nagendra