I am trying this on my Custom JavaScript button
IF( '{!Account.recordtype.name}' ='First RecordType'){
// Do Something
}
ELSE{
// Do something else
}
and when I click on "Check Syntax" I got this error -
Error: Field Account.recordtype.name does not exist. Check spelling.
Answer : Please correct if I am missing something/doing in wrong way in below code- to get what I want.
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}
var recordtypeResult1 = sforce.connection.query("Select id FROM RecordType WHERE Name='First RecordType'");
var recordType1 = recordtypeResult1.getArray("records");
var recordtypeResult2 = sforce.connection.query("Select id FROM RecordType WHERE Name='Second RecordType'");
var recordType2 = recordtypeResult2.getArray("records");
if( ('{!Account.recordtypeid}'== recordType1[0].Id || '{!Account.recordtypeid}' ==recordType2[0].Id)
{
//DO Something
}
Any help or suggestions ??!