Related to my latest flurry of questions, I am trying to write the Record Type Name as a String data type into a text DML Log custom object field.
You will likely be able to tell by my code that I have been banging my head against the wall on this one for a while:
SObject_Record_Type__c = (String) sobj.getSObjectType.getDescribe().getRecordTypeInfosById().getName()
This is the farthest I have come, and it throws this compile error:
Field expression not allowed for generic SObject at line 11 column 68
I would continue to bang my head against this and scour the Sobj method documentation (as I have already), but I am against a deadline and feel I am missing something big-- What is the next step in successfully writing the sObject's Record Type name into the text field?
EDIT: Here is the latest update to that statement (shoutout to cropredy for the help):
Name__c = (String) sobj.get('name'), SObject_Id__c = (Id) sobj.get('Id'), SObject_Record_Type__c = sobj.getSobjectType().getDescribe().getRecordTypeInfos().size() <= 1 // master recordtype will exist in describe even if no others ? null : (String) sobj.get('recordtypeId')
This has worked in passing the RecordTypeId to the field, but I am trying to pass the Record Type Name in to that field.
Does it make sense to just assign this new statement to a temporary variable, then do a .getName() lookup against that variable and pass it into the custom object's field?