0

I am implementing a function used to update the picklist values for a given record type. When I retrieve the metadata for the record type, I am receiving null for its properties. My code:

// Create service
MetadataService.MetadataPort service = new MetadataService.MetadataPort();
service.SessionHeader = new MetadataService.SessionHeader_element();
service.SessionHeader.sessionId = UserInfo.getSessionId();

// Read metadata
MetadataService.RecordType recordType = (MetadataService.RecordType) service.readMetadata('RecordType', new String[] { 'Account.Record_Type_A' }).getRecords()[0];

System.debug(recordType); // Has nulls for its properties
System.debug(recordType.fullName); // null

Record Type: enter image description here

System.debug(recordType):

14:10:14.0 (162607043)|USER_DEBUG|[23]|DEBUG|RecordType:[Metadata.fullName=null, active=null, active_type_info=(active, http://soap.sforce.com/2006/04/metadata, null, 1, 1, false), apex_schema_type_info=(http://soap.sforce.com/2006/04/metadata, true, false), businessProcess=null, businessProcess_type_info=(businessProcess, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), compactLayoutAssignment=null, compactLayoutAssignment_type_info=(compactLayoutAssignment, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), description=null, description_type_info=(description, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), field_order_type_info=(fullName, active, businessProcess, compactLayoutAssignment, description, label, picklistValues), fullName=null, fullName_type_info=(fullName, http://soap.sforce.com/2006/04/metadata, null, 0, 1, false), label=null, label_type_info=(label, http://soap.sforce.com/2006/04/metadata, null, 1, 1, false), picklistValues=null, picklistValues_type_info=(picklistValues, http://soap.sforce.com/2006/04/metadata, null, 0, -1, false), type=RecordType, type_att_info=(xsi:type)]

Other posts said the proper way to read the record type's metadata with the format "<Object API Name>.<Record Type Developer Name>" but this still doesn't work for me. Thanks for reading and your time, let me know if there is something I might be missing.

Best, Blake

1 Answer 1

1

Record Types need to have their namespace included with "<Object API Name>.<Namespace Prefix + __><Record Type Developer Name>".

I was able to solve this by modifying the readMetadata call:

MetadataService.RecordType recordType = (MetadataService.RecordType) 
    service.readMetadata('RecordType',
                         new String[] { 'Account.AQB__Record_Type_A' })
        .getRecords()[0];
1
  • 1
    we really appreciate these self-answered questions to aid the community
    – cropredy
    Commented Jan 25 at 23:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .