I have used the below method of getting RecordTypeIds for any record many times and it has worked for me-
Id RTid = Order.sObjectType.getDescribe().getRecordTypeInfosByName().get('Export Order').getRecordTypeId()
wierdly, it's throwing an error today for a specific class whereas in another class is getting compiled-
Error: Compile Error: Invalid field sobjecttype for SObject Order at line x column y
The same method executes well in Anonymous Apex.
Any ideas what I'm doing wrong.
For the time being I've changed my code to
Id RTid = Schema.SObjectType.Order.RecordTypeInfosByName.get('Export Order').RecordTypeId;;