+ Start a Discussion
LinThawLinThaw 

Get Picklist value by RecordType

Hi there,
According to our trailhead module, we can get picklist value by Object Name and Field Name.
Trailhead Module (https://trailhead.salesforce.com/en/content/learn/projects/workshop-override-standard-action/override_2)
@AuraEnabled        
public static List<String> getPickListValuesIntoList(String objectType, String selectedField){
    List<String> pickListValuesList = new List<String>();
    Schema.SObjectType convertToObj = Schema.getGlobalDescribe().get(objectType);
    Schema.DescribeSObjectResult res = convertToObj.getDescribe();
    Schema.DescribeFieldResult fieldResult = res.fields.getMap().get(selectedField).getDescribe();
    List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
    for( Schema.PicklistEntry pickListVal : ple){
        pickListValuesList.add(pickListVal.getLabel());
    }     
    return pickListValuesList;
}

I want to add RecordTypeId to that method.
Any good idea for that?
Thank in advance.
Regards,
LinThaw
AbhishekAbhishek (Salesforce Developers) 
Hi,

For all the Trailhead issues please report it here,

https://trailhead.salesforce.com/help?support=home#

https://trailhead.salesforce.com/help

So that our trailhead support engineers will look into it and get back to you.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Regards,
​​​​​​​Salesforce Support.
Raghav Sharda 28Raghav Sharda 28
Hi LinThaw,
String objectType	='Opportunity';
Schema.SObjectType convertToObj = Schema.getGlobalDescribe().get(objectType);
Schema.DescribeSObjectResult res = convertToObj.getDescribe();

List<Schema.RecordTypeInfo> RT = res.getRecordTypeInfos();

for(Schema.RecordTypeInfo recInfo :RT){
    system.debug('AllRecordTypeName------------->'+recInfo.getName());
}

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks & regards
LinThawLinThaw
I mean that I want to add parameter to get picklist value by RecordTypeId.
public static List<String> getPickListValuesIntoList(String objectType, String selectedField, String recordTypeId)
Regards,
LinThaw
Jhili Patra 2Jhili Patra 2
Hello LinThaw,
Hope you are doing great. I saw you have solved issue for superbedge #3 and I am really looking forward you to help me in solving my issue.

I am struck at #3 with below error.

I am uploading .json Any suggesstion on this plz.

User-added image

{
  "Filter Agency Records": {
    "action": "filter",
    "parameters": {
      "filter": "IsAgency:EQ:TRUE",
      "source": "ID Agency Records"
    }
  },
  "Load Account": {
    "action": "sfdcDigest",
    "parameters": {
      "fields": [
        {
          "name": "Name"
        },
        {
          "name": "AccountNumber"
        },
        {
          "name": "Phone"
        },
        {
          "name": "ShippingCity"
        },
        {
          "name": "ShippingCountry"
        },
        {
          "name": "ShippingState"
        },
        {
          "name": "ShippingStreet"
        },
        {
          "name": "ShippingPostalCode"
        }
      ],
      "object": "Account"
    }
  },
  "Create Seed Bank Agencies": {
    "action": "sfdcRegister",
    "parameters": {
      "name": "Seed Bank Agencies",
      "alias": "seed_bank_agencies",
      "source": "Add Agency Fields"
    }
  },
  "Add Agency Fields": {
    "action": "augment",
    "parameters": {
      "right_key": [
        "AccountNumber"
      ],
      "left": "Filter Agency Records",
      "left_key": [
        "AccountNumber"
      ],
      "right_select": [
        "Currency",
        "Region",
        "SubRegion",
        "Latitude",
        "Acres",
        "Longitude"
      ],
      "right": "Load Agency Detail",
      "relationship": "AgencyDetail",
      "operation": "LookupSingleValue"
    }
  },
  "Load Agency Detail": {
    "action": "edgemart",
    "parameters": {
      "alias": "Agency_Detail"
    }
  },
  "ID Agency Records": {
    "action": "computeExpression",
    "parameters": {
      "source": "Load Account",
      "mergeWithSource": true,
      "computedFields": [
        {
          "name": "IsAgency",
          "saqlExpression": "case when Phone is not null then \"TRUE\" else \"FALSE\" end",
          "label": "IsAgency",
          "type": "Text"
        }
      ]
    }
  }
}

Thanks in Advance.