39

Clues came from here: http://sfdciq.com/unable-to-delete-record-type/ The solution is a URL hack. https://xxx.salesforce.com/setup/ui/profilerecordtypeedit.jsp?id={Profile ID}&tid={Custom Object ID}&pn={Profile Name} Eg, As a System Administrator, I go to Setup > Profiles > the profile I'm interested in. Lets say "Chatter External User" The url ...


32

Until now, we used zachelrath's solution, and it worked wonderfully. As of v43.0 (Summer '18), however, the proper way to do this is to simply use getRecordTypeInfosByDeveloperName. It eliminates a good chunk of code, eliminates a database hit (SOQL limit), and preserves the stability of using the RecordType's DeveloperName. Also, there are no longer ...


19

Actually, that is not quite true. Name is the field that the user sees when they choose it in the screen (or on the Page Layout). Developer Name is the API name for the record. This is very similar to the way the Label and the API Name work for fields and object. Because of this, it is best practice to always use Developer Name, since it is less likely to ...


18

If you are doing this in the trigger it would be something like this: trigger OnOpportunity on Opportunity(before update){ Map<ID,Schema.RecordTypeInfo> rt_Map = Opportunity.sObjectType.getDescribe().getRecordTypeInfosById(); for(Opportunity opp : trigger.new){ if(rt_map.get(opp.recordTypeID).getName().containsIgnoreCase('YOUR ...


15

getRecordTypeInfosByName() looks for Label. After summer '18 preview, Salesforce is going to support getRecordTypeInfosByDeveloperName() delivered: https://developer.salesforce.com/docs/atlas.en-us.214.0.apexcode.meta/apexcode/apex_methods_system_sobject_describe.htm Example: (Change your record type developer name in below example) system.debug(Case....


14

It's RecordType.Name RecordTypes are held in separate reference table so to query the names just treat the RecordTypeId as any other lookup field :) In case you've never used the "dot notation" (the way SOQL handles relationships and things that would be JOINs in regular databases): http://www.salesforce.com/us/developer/docs/dbcom_soql_sosl/Content/...


14

By querying the recordType object and filtering by the sObjectType select Id,Name from RecordType where sObjectType='Account'


13

While this can be accomplished with SOQL, SOQL queries are a precious resource and we have but a scant few in each transaction. There is a way to get this information without using a single query by using SObjectDescribe. // The general expression to use is // Schema.SObjectType.<your SObject's API name here>.getRecordTypeInfosByName() // I'll be ...


13

Summer'18 update provided a new interface 'lightning:hasPageReference'. You can now access the recordTypeId in your controller as below: var recordTypeId = component.get("v.pageReference").state.recordTypeId; https://developer.salesforce.com/docs/component-library/bundle/lightning:hasPageReference/documentation


12

You can make use the User Interface API to get picklist values based on record type, https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_resources_picklist_values.htm However, you need to make a REST API call and set Remote Site Settings. Here is the sample code for that, Http http = new Http(); HttpRequest request = new HttpRequest()...


12

You need to set the Id not the name. First fetch the Id Id stExam = Schema.SObjectType.Student_Records__c.getRecordTypeInfosByName().get('Student Exam Records').getRecordTypeId(); and then assign it endterm.RecordtypeId= stExam;


9

You can use the RecordTypeInfo class to get a list of record types without using a query, and select one based on the name of the record type.


9

Only the object's base fields are loaded from the database in triggers. To get related objects, you need to either query for them or use describe calls. In this specific case, you would use a describe call: Map<Id, RecordTypeInfo> rtinfos = Financial_Account__c.getDescribe().getRecordTypeInfosById(); for(Financial_Account__c record: Trigger.new) { ...


9

I finally found the answer to this after hours of searching. This happens when you have setup a community audience that references the record type you are attempting to deactivate. It seems as though the platform isn't able to route you to the audience as the reference that is invalid, and I couldn't find any documentation on the FieldBasedPAC object, which ...


8

I have found the solution by using fullName Admin which is got by querying Profile Object using listMetadata() method of MetadataConnection. The list of fullName of Standard Profiles then returned are as follows: SolutionManager Customer Portal Manager Standard StandardAul Standard Chatter Free User Chatter External User ContractManager Customer Portal ...


8

To accomplish a number of date-dependent pieces of work we run a Scheduled Job - a class that implements Schedulable - every night. That job can then kick-off a chain of classes that implement Database.Batchable. These avoid governor limit issues by breaking their work up into multiple batches passed to the execute method, each with its own governor limits. ...


8

If you have a deep stack of dependent triggers (and some Orgs do) you can save yourself a SOQL by adding a formula field to the opportunity object, with a return type of Text, and a value of RecordType.Name If for example the formula field is called RecordTypeName you can access it directly in the trigger without querying again. for(Opportunity opp : ...


8

yes the record type ids will be the same. And that's not just for record types, field ids and any object prefixes (first three parts of a record id) will also be the same. they will differ. If you create record types, fields or objects their ids will be different once deployed to production. yes once they are refreshed from production.


8

it will be possible from Summer'18 https://releasenotes.docs.salesforce.com/en-us/summer18/release-notes/rn_apex_developer_name.htm Get the Developer Name for Record Types More Easily We added Apex methods to help you get the developer name for record types more easily. Previously, the developer name was accessible only via SOQL on the RecordType SObject, ...


8

Documentation about RecordTypeId field on CampaignMember says: ID of the record type assigned to this object. To change the record type, modify the CampaignMemberRecordTypeId field on the associated Campaign. so you can't assign record type to CampaignMember record in this way. Select related Campaign and change CampaignMemberRecordTypeId field


8

Please recompile all classes in org by using compile all classes link on apex classes page under setup or you can do runAllTest in org which will recompile the covered classes. This will fix the issue. We faced a similar issue after Summer 19 release and got it fixed by recompiling all the classes.


8

Use the GetRecords Element and Query on Groups. Add the filter to make sure Type = Queue, then add the filter for DeveloperName = (queue name).


7

Time based workflow is perfect for this. The workflow turns off automatically when the criteria changes. Scheduled Apex will also work, but isn't needed. Batch Apex would ensure you can scale to large data volumes. From Help & Training Time-dependent actions remain in the workflow queue only as long as the workflow rule criteria are still valid. ...


7

If you are interested in solution which would work only for Salesforce Classic, I have it. It is possible to make Tooling API ProfileLayout Object Query [ select Layout.Name from ProfileLayout where ProfileId = :UserInfo.getProfileId() AND RecordTypeId = :record.RecordTypeId ] To make it possible to use in Apex Code you need preparation step. 1) Allow ...


7

Record types are not separate object. Adding extra column in your CSV file with RecordTypeID should work. So while inserting from Test.Load(), record will be created based on record types. Alternately if there is change in recordtypeid use below syntax to get RecordtypeId and logic. Example code: Id RecordTypeIdValue = Schema.SObjectType.Account....


7

You can query the RecordType object to find out the record types that way. List<RecordType> rts = [select Id from RecordType where SObjectType = :MyObject__c.SObjectType ]; if (rts.size() > 0) { // MyObject__c has record types }


7

DeveloperName is not the same as Name. It has special restrictions, much like API names (can't start with a number, no spaces or punctuation, etc). Check the Developer Name attribute of your record type. The formula editor won't throw an error, but you'll never match a DeveloperName to a string that contains spaces. From the documentation: Required. The ...


7

It's not entirely clear in the documentation on the gerRecordTypeInfosByName() method, but the documentation does make a mention of using the 'label' getRecordTypeInfosByName() Returns a map that matches record labels to their associated record type. The current user is not required to have access to a record type to see it in this map. I don't know ...


7

Use a unique identifier wherever possible to query for vital configuration data. In this case, DeveloperName is unique, where Name is not. So there is a clear and compelling case to use the former.


6

No, it's not possible to create RecordTypes from Apex, since RecordType doesn't support DML. It's likely possible to achieve your ends some other way - for example, see this answer to a similar question.


Only top voted, non community-wiki answers of a minimum length are eligible