Skip to main content

Return to TX Community

Liaison

Object Dictionary Upgrade

Step 1: Manually add the code changes via a Change Set  

Object Dictionary is an unmanaged package, so you must manually add the code changes for the Object Dictionary package via a Change Set. You must complete the steps in a sandbox environment before pushing to production via an Outbound Change Set. 

Your starting package version number determines what, if any, additional configuration steps may be required. Please click the link for your initial version number (identified in Step 1 above) from the list below. You will be directed to the first step required for your upgrade and should complete all steps that follow. If you do not see your version number listed, please get in touch with the TargetX Support team. 

Step 2 - Log into your Sandbox 

Ensure that your sandbox has been refreshed before continuing.

Starting Version

This is the version you currently have installed, as Identified in Step 1.

Ending Version

This is the upgrade you are installing, as selected in Step 2.  

Configuration Steps by Release

These are the steps you need to complete, from the starting version to the ending version. For example, if your starting version is 2205.0 (May '22) and you're upgrading to 2208.6 (August '22), you'll need to complete the configuration steps for 2206.3 (June '22), 2207.0 (July '22), and 2208.6 (August '22). 

1.0 September '26

Item 1: Edit the objectDictionaryController Apex class

1.    Navigate to Setup and search for Apex class.
2.    Locate the objectDictionaryController class and click Edit.
3.    Replace the code with the following, or click here to download:

public class objectDictionaryController{
    
    public List<Schema.sObjectType> objectSchema {get; set;}
    public List<Schema.sObjectType> objectSchemaFiltered {get; set;}
    public Set<String> namespaces {get; set;}
    public String displayObjects {get; set;}
    public string selectedObjectGroup {get; set;}
    public string selectedObject {get; set;}
    public List<String> fieldsToDisplay{get; set;}
    public List<SelectOption> types {get; set;}
    public String selectedType {get; set;}
    public List<fieldProfile> fieldProfiles {get; set;}
    public List<SelectOption> objectGroups {get; set;}
    public List<SelectOption> objects {get; set;}
    public boolean selectAll {get; set;}
    public List<fieldProfile> selectedFields {get; set;}
    public string headerRow {get; set;}
    //public Map<String,Data_Mapping__c> dataMappingMap {get; set;}
    
    public objectDictionaryController(){
        objectSchema = Schema.getGlobalDescribe().Values();
        objectSchemaFiltered = new List<Schema.sObjectType>();
        Map<String, Schema.SObjectType> globalDescribe = Schema.getGlobalDescribe();
        namespaces = new Set<String>();
        objects = new List<SelectOption>();
        displayObjects = 'Label';
        fieldsToDisplay = new List<String>();

        for(Schema.sObjectType obj : objectSchema){
            if(string.valueOf(obj).countMatches('__')==2){
                namespaces.add(
                    string.valueOf(obj).substring(0, string.valueOf(obj).indexOf('__'))
                );
            }
            Schema.DescribeSObjectResult describeResult = globalDescribe.get(string.valueOf(obj)).getDescribe();
            if(!string.valueOf(obj).endsWith('Share') &&
                !string.valueOf(obj).endsWith('Feed') &&
                !string.valueOf(obj).endsWith('History') &&
                !string.valueOf(obj).endsWith('ChangeEvent') &&
                !string.valueOf(obj).endsWith('Tag') &&
                describeResult.isSearchable()) {
                    objectSchemaFiltered.add(obj);
               }
        }
        buildObjectGroupList();
        
        types = new List<SelectOption>{
                        new SelectOption('',''),
                        new SelectOption('ALL','All'),
                        new SelectOption('BOOLEAN','Boolean'),
                        new SelectOption('COMBOBOX','ComboBox'),
                        new SelectOption('CURRENCY','Currency'),
                        new SelectOption('DATACATEGORYGROUPREFERENCE','DataCategoryGroupReference'),
                        new SelectOption('DATE','Date'),
                        new SelectOption('DATETIME','DateTime'),
                        new SelectOption('DOUBLE','Double'),
                        new SelectOption('EMAIL','Email'),
                        new SelectOption('ENCRYPTEDSTRING','EncryptedString'),
                        new SelectOption('ID','Id'),
                        new SelectOption('INTEGER','Integer'),
                        new SelectOption('MULTIPICKLIST','MultiPicklist'),
                        new SelectOption('PERCENT','Percent'),
                        new SelectOption('PHONE','Phone'),
                        new SelectOption('PICKLIST','Picklist'),
                        new SelectOption('REFERENCE','Reference'),
                        new SelectOption('STRING','String'),
                        new SelectOption('TEXTAREA','TextArea'),
                        new SelectOption('TIME','Time'),
                        new SelectOption('URL','URL')
                    };        
    }
    
    public List<SelectOption> buildObjectGroupList(){
        objectGroups = new List<SelectOption>{new selectOption('',''),new selectOption('Standard Objects','Standard Objects'),new selectOption('Custom Objects','Custom Objects')};
        for(String ns : namespaces){
            objectGroups.add(new selectOption(ns,ns));
        }
        objectGroups = SortSelectOptions.selectOptionSortByLabel(objectGroups);
        return objectGroups;
    }
    
    public pageReference buildObjectList(){
        selectedType = '';
        objects = new List<SelectOption>();
        if(selectedObjectGroup != '' && selectedObjectGroup != NULL){
            if(selectedObjectGroup == 'Standard Objects'){
                for(Schema.sObjectType obj : objectSchemaFiltered){
                    if(!string.valueOf(obj).contains('__')){
                        if(displayObjects == 'Label') {
                            objects.add(new SelectOption(string.valueOf(obj), obj.getDescribe().getLabel() ) );
                        } else if (displayObjects == 'Name') {
                            objects.add(new SelectOption(string.valueOf(obj), string.valueOf(obj) ) );
                        }
                    } 
                }
            } else if(selectedObjectGroup == 'Custom Objects'){
                for(Schema.sObjectType obj : objectSchemaFiltered){
                    if(string.valueOf(obj).countMatches('__') == 1){
                        if(displayObjects == 'Label') {
                            objects.add(new SelectOption(string.valueOf(obj), obj.getDescribe().getLabel() ) );
                        } else if (displayObjects == 'Name') {
                            objects.add(new SelectOption(string.valueOf(obj), string.valueOf(obj) ) );
                        }
                    } 
                }
            } else {
                for(Schema.sObjectType obj : objectSchemaFiltered){
                    if(string.valueOf(obj).startsWith(selectedObjectGroup)){
                        if(displayObjects == 'Label') {
                            objects.add(new SelectOption(string.valueOf(obj), obj.getDescribe().getLabel() ) );
                        } else if (displayObjects == 'Name') {
                            objects.add(new SelectOption(string.valueOf(obj), string.valueOf(obj) ) );
                        }
                    } 
                }
            }
        }
        objects.add(new SelectOption('',''));
        objects = SortSelectOptions.selectOptionSortByLabel(objects);
        return null;
    
    }
    
    public PageReference fieldResult() {
                    
                    if(selectedObject != NULL && selectedType != NULL) {
                        //getMappings();
                        selectAll = false;
                        Map<String, Schema.SObjectField> fieldMap = (Schema.getGlobalDescribe().get(string.valueOf(selectedObject))).getDescribe().fields.getMap();
                        fieldsToDisplay = new List<String>();
                        fieldProfiles = new List<fieldProfile>();
                        
                        for (string fld : fieldMap.keySet()) {    
                                if(string.valueOf(fieldMap.get(fld).getDescribe().getType() ) == selectedType) {
                                    fieldsToDisplay.add(fld);
                                } else if(selectedType == 'ALL' || selectedType == '') {
                                    fieldsToDisplay.add(fld);
                                }
                        }

                            for (string fieldName : fieldsToDisplay ) {
                                Schema.DescribeFieldResult fieldDescribe = fieldMap.get(fieldName).getDescribe();
                                
                                fieldProfile fp = new fieldProfile();
                                    fp.apiName=fieldName;
                                    fp.label=fieldDescribe.getLabel();
                                    fp.Type=string.valueOf(fieldDescribe.getType());
                                    fp.isExternalId=fieldDescribe.isExternalId();
                                    fp.length=fieldDescribe.getLength();
                                    fp.isFormula=fieldDescribe.isCalculated();
                                    fp.isUnique=fieldDescribe.isUnique();
                                    fp.picklistValues=new List<String>();                                   
                                    fp.isUpdateable=fieldDescribe.isUpdateable();
                                    //fp.dataMapping=dataMappingMap.get(fieldName);

                                List<String> picklistEntries = new List<String>();
                                
                                if(fp.Type == 'PICKLIST' || fp.Type == 'MULTIPICKLIST') {
                                    List<Schema.PicklistEntry> picklistValues = fieldDescribe.getPicklistValues();
                                    for(Schema.PicklistEntry ple : picklistValues) {
                                        picklistEntries.add(ple.getLabel() );
                                    }
                                    fp.picklistValues = picklistEntries;
                                
                                } else if(fp.Type == 'REFERENCE') {
                                    fp.Reference = string.valueOf(fieldDescribe.getReferenceTo());
                                    
                                } else if(fp.Type == 'DOUBLE') {
                                    fp.Precision = fieldDescribe.getPrecision();
                                } else {

                                    
                                }
                                

                                fieldProfiles.add(fp);
                                }

                        }

                    return null;
                        
                    }
    
    //public void getMappings(){
        //List<Data_Mapping__c> dataMappings = new List<Data_Mapping__c>([SELECT Id, Name, Salesforce_Field_API_Name__c, External_System_Field__c, Mapping_Instructions__c FROM Data_Mapping__c WHERE Salesforce_Object__c = :selectedObject]);
        //dataMappingMap = new Map<String, Data_Mapping__c>();
        //for(Data_Mapping__c dm : dataMappings){
        //    dataMappingMap.put(dm.Salesforce_Field_API_Name__c, dm);
        //}
    //}                
    
    public pageReference updateSelectedFieldList(){
    
        selectedFields = new List<fieldProfile>();
        for(fieldProfile fp : fieldProfiles){
            if(fp.isSelected){selectedFields.add(fp);}
        }
        if(selectedFields.size() == 0){
            selectAll = false;
            } 
    
    return null;
    }
    
    public pageReference selectAllFields(){
        selectedFields = new List<fieldProfile>();
        for(fieldProfile fp : fieldProfiles){
            if(selectAll){
                fp.isSelected = true;
                selectedFields.add(fp);
                } else {
                fp.isSelected = false;
                }
            
        } 
    
    return null;
    }
    
    public pageReference generateImportTemplate(){
        updateSelectedFieldList();
        
        if(selectedFields.size() == 0){
        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'No fields selected.'));
        return null;
        } else {
        headerRow = '';
        for(fieldProfile fp : selectedFields){
            headerRow += fp.apiName + ',';
        }
        return Page.objectImportHeader;
        }
    }
    
    public class fieldProfile{
        public string apiName {get; set;}
        public string label {get; set;}
        public string Type {get; set;}
        public List<string> picklistValues {get; set;}
        public boolean isExternalId {get; set;}
        public integer Length {get; set;}
        public string Reference {get; set;}
        public boolean isFormula {get; set;}
        public integer Precision {get; set;}
        public boolean isUnique {get; set;}
        public boolean isUpdateable {get; set;}
        public boolean isSelected {get; set;}
        //public Data_Mapping__c dataMapping {get; set;}
        
        public fieldProfile(){
            Reference='';
            Precision=0;
            //dataMapping=new Data_Mapping__c();
        }

    }
    
    public PageReference export() {
            updateSelectedFieldList();
            if(selectedFields.size() == 0){
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'No fields selected.'));
                return null;
            } else {
            return Page.objectDictionaryExport;
            }
        }

}
  1. Save your changes.
    Item 3: Test the Changes in Your Sandbox  
    Item 4: Create an Outbound Change Set 
    1. Navigate to Setup and search for Outbound Change Sets.
    2. Select New.
    3. Name the Change Set, for example, Object Dictionary Upgrade September '26.
    4. Add a Description and Save your changes.
    5. In the Change Set Components section, select Add.
    6. Select a Component Type of Apex Class, depending on your changes.
    7. Click the checkboxes for the Apex Class you updated in previous steps, depending on your starting version. For example:
       

      Upgrading from 1.0

      Apex Class:

      • objectDictionaryController
    Item 5: Upload your Change Set 
    1. From the Change Set, you created above, select the Org to which you want to send the Change Set.
    2. Click Upload.

    Note: Uploading the Change Set will send it to the Target Org; it will NOT make changes in your production Org until you Deploy the Change Set.

    Item 6: Validate the Change Set in your Production Org  
    1. Login to your production Org.
    2. Navigate to Setup and search for Inbound Change Sets.
    3. The Change Set you uploaded should be available under Change Sets Awaiting Deployment.
    4. Click the Change Set you want to deploy.
    5. Click Validate.
    Item 7: Deploy the Change Set in your Production Org  
    1. Login to your production Org.
    2. Navigate to Setup and search for Inbound Change Sets.
    3. The Change Set you uploaded should be available under Change Sets Awaiting Deployment.
    4. Click the Change Set you want to deploy.
    5. Click Deploy. For additional information on deploying Change Sets, please see Salesforce Help & Training article "Deploying a Change Set"
    Item 8: Your upgrade is complete  
    1. No further configuration is required. You should proceed to TargetX Integration.

     

    • Was this article helpful?