+ Start a Discussion
sangeeta.marathe@Futurewise.cosangeeta.marathe@Futurewise.co 

SOQL query

    Account  Clientacc =new Account(LastName='ABC',PersonMailingStreet='Street',PersonMailingCity='City',

                    PersonMailingState='state',PersonMailingCountry='country',

                    PersonMailingPostalCode='123456',FirstName='DEF',Retirement_Age__c='55',

                    Estimated_Life_Expectancy__c='85',PersonBirthdate=system.today(), RecordTypeId='01220000000DnK3AAK');

 

The above query is giving me the error as bad field name FirstName ,LastName....

When i check in my Account i see FirstNAme and LastName in the standard field list.........

I am working on Person Account....

Y is my query not getting accepted....

Can i get a solution for the same......

Sonali BhardwajSonali Bhardwaj

For business Account we don't have firstname or lastname. FirstName and LastName fields are only for person account.

 

You need to provide a person account record type id in your query. May be the id you are passing is a business account record type.

 

 

sangeeta.marathe@Futurewise.cosangeeta.marathe@Futurewise.co

thanks in that case can u tell me how do i fetch person account RecordTypeId

sangeeta.marathe@Futurewise.cosangeeta.marathe@Futurewise.co

These are all person account fields in which i am inserting that values....

Sonali BhardwajSonali Bhardwaj

You are hard coding RecordTypeId. How did you find that? In the same way you have to find person account RecordTypeID. There could many record type for person account in your org, go to the one you are interested in and copy the id from URL.

sangeeta.marathe@Futurewise.cosangeeta.marathe@Futurewise.co

The Above query that i have posted is in my test class where I am trying to insert the values and test the code.

for getting the RecordTypeId I used the follwoing query

Select id from RecordType where sobjecttype='Account'

i just got the Id from there and then used them in my test class

Sonali BhardwajSonali Bhardwaj

try

Select id from RecordType where sobjecttype='Account' and Name="your person account record type name"

sangeeta.marathe@Futurewise.cosangeeta.marathe@Futurewise.co

I am just having default Record Type as Person Account...

using that in the query i got only one Id

sangeeta.marathe@Futurewise.cosangeeta.marathe@Futurewise.co

and the Same RecordType Id is being used in my query also....

sangeeta.marathe@Futurewise.cosangeeta.marathe@Futurewise.co

I am not able to sove thie particular error......

can i get some help on it

 

Sonali BhardwajSonali Bhardwaj

Go to list of your record type of person account. What all record types you have? Mention any one's name in the query I mentioned in my last post.

sangeeta.marathe@Futurewise.cosangeeta.marathe@Futurewise.co

I Executed that query 

got the Id for my two record types.

but then too when i am using this particular IS its telling me

  BAD FIELD NAME LAST NAME AND FIRSTNAME

David81David81

If you only have one person account record type, you can just leave that out and it will assign it automatically. You'll only have to assign the record type Id if you have more than one Person Account Record Type. By defining a FirstName and LastName, SFDC automatically creates a Person Account.