You need to sign in to do that
Don't have an account?

Invalid field RecordTypeId for SObject Asset
Hi ,
Below is the code in test class .
Account acc= new Account( Name= 'testName', Phone ='0987654321', Customer_ID__c='111111111111' );
insert acc;
Id recId2 =[Select Id from RecordType where DeveloperName = 'Card' ].ID;
system.debug('rec Id2----'+recId2);
Asset assetRec = new Asset(Name='test' ,AccountId = acc.Id, Asset_Number__c='123456789012345',Status='Inactive',RecordTypeId=recId2);
insert assetRec;
Asset assetRec2 = new Asset(Name='test2',AccountId = acc1.Id, Asset_Number__c='456789123852741',Status='Active' );
insert assetRec2 ;
This is giving an error "Invalid field RecordTypeId for SObject Asset"
I am runnign this as System Admin and have all required permissions for record Types
Running on version 37.0
Please help me understand if i am missing anything .
Thanks,
Sailaja
Below is the code in test class .
Account acc= new Account( Name= 'testName', Phone ='0987654321', Customer_ID__c='111111111111' );
insert acc;
Id recId2 =[Select Id from RecordType where DeveloperName = 'Card' ].ID;
system.debug('rec Id2----'+recId2);
Asset assetRec = new Asset(Name='test' ,AccountId = acc.Id, Asset_Number__c='123456789012345',Status='Inactive',RecordTypeId=recId2);
insert assetRec;
Asset assetRec2 = new Asset(Name='test2',AccountId = acc1.Id, Asset_Number__c='456789123852741',Status='Active' );
insert assetRec2 ;
This is giving an error "Invalid field RecordTypeId for SObject Asset"
I am runnign this as System Admin and have all required permissions for record Types
Running on version 37.0
Please help me understand if i am missing anything .
Thanks,
Sailaja
A recordtype is associated with an object (sObjecttype). "Card" can exists as a recordtype yet but not for the SObject Asset.
Alain
I tried by changing the query but it still didnt work .Giving the same error .
Invalid field RecordTypeId for SObject Asset
1) Verify if your recordtype is Active.
2) try this new syntax with the Name of your record type (not the developer name)
Id recId2 = Schema.SObjectType.Asset.getRecordTypeInfosByName().get('Card').getRecordTypeId();
( for me with the example above: Id recId2 = Schema.SObjectType.Asset.getRecordTypeInfosByName().get('agency1').getRecordTypeId(); )
Alain
I think the problem is not with the record type .
Becuase i am getting valid record type id .
The issue is i am not able to save the code becuase of this compiler error and this comes while creating Asset with field name as RecordTypeId .
Thanks,
Sailaja