function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Biswajit Nath 9Biswajit Nath 9 

Getting error from Line 3, ERROR: Type requires name=value pair construction: RecordType

I have  a piece of code where I am getting error at line 3:
public static list<Account> createaccount(Integer numberofrec){
        List<Account> accounts = new list<Account>();
        RecordType recid = New RecordType([Select Id, name From RecordType where sobjecttype = 'Account' and name ='Account_New_Page_Assignment']);
  Colleague__c colleague = new Colleague__c();
  colleague = createcolleague(1)[0];
        for (Integer i = 0; i< numberofrec; i++){
            Account account = new Account(recordtypeid = recid.Id, Name = 'Test Account' + Math.random(), Relationship_Manager__c = colleague.Id , Country__c = 'India - IN' );
   accounts.add(account);
        }
  return accounts;



Can anybody help me out ? Many thanks in advance.
v varaprasadv varaprasad
Hi Biswajit,

RecordType recid = New RecordType([Select Id, name From RecordType where sobjecttype = 'Account' and name ='Account_New_Page_Assignment']);
   Remove above line instead of that use below lines either 1 or 2 :

is it Account_New_Page_Assignment recordtype label name or API name.

In below querys, we need  to use  record type label name.

1.  RecordType recid = [Select Id, name From RecordType where sobjecttype = 'Account' and name ='Account_New_Page_Assignment'].id;
2. Id recid = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Account_New_Page_Assignment'').getRecordTypeId();

Hope this helps you.

Thnks
Varaprasad