13

getInstance method is a new addition that is supported on api version v51 and upwards. You need to update your DealTriggerHandler class api version to 51. Here is the relevant documentation


6

The query limit does not apply (unless you select a rich text field). However, the row limit still applies. This conclusion can easily be proven by running a simple script: List<My_Metadata__mdt> metadata = [SELECT DeveloperName FROM My_Metadata]; system.assertEquals(0, Limits.getQueryRows(), 'This assertion fails because the row limit is consumed');


6

You'll need to store the secrets in environment variables in your build system, and inject them just prior to initiating uploads of 2GP managed package versions. Your source tree would contain only some arbitrary token that is the replacement target. I'll keep this example somewhat abstract to account for differences in what CI or build system you actually ...


4

CMDT Queries performed in Apex do not count against the limit. They are specifically referencing queries performed by Get Records. I actually did take the time to test this, as @cropredy suggested, and successfully performed 1000 CMDT queries in a single Apex Action without a problem.


4

SOLID is something that tends to happen when you write good code, but good code is not necessarily something that happens when you implement SOLID. In other words, SOLID is a description of what good code looks like, not a prescription for getting good code in the first place. I can, for example, write very SOLID code that will crash in any Salesforce org ...


4

Can we pass myCustomMetadataList that was fetched from the LWC into the trigger such that myMethod() can access the same myCustomMetadataList variable from the LWC without making a custom metdata query again? No. One is client-side, the other is server-side. You could do this in Apex (not a trigger), but this is (probably) a waste of bandwidth. How can we ...


4

In a recent AppExchange Tech Talk, Salesforce revealed that they will allow cross-namespace use of exposed LWCs. This would, for example, allow a package developer to create a component, let's call it "example", in their package with a namespace prefix we'll call "funky" and have it available for use by third parties (my highlighting in a ...


4

The error is here: Decimal amount = trans.Balance__c * ir; You're trying to multiply a record against a number. This is not allowed. You probably meant: Decimal amount = trans.Balance__c * ir.Interest_rate__c;


3

I'd probably design this to not include any Custom Metadata records in the base package, and have a separate, dependent unlocked package that stores the Metadata records. This way, updating the base package would no longer affect the dependent packages' values, as they would only need to configure it once. You could also just not include any records, and ...


2

From Spring 21 there is new way for accessing record inside Custom Metadata. Accessing specific record: ObjectName__mdt.getInstance('RecordName'); Accessing all records (and you can loop them): ObjectName__mdt.getAll(); In your case, you can use getAll() method and loop into them and compare them. Example: Map<String, ObjectName__mdt> mapCMD = ...


2

In terms of your questions at the end: No, there's nothing clever here, unfortunately. Relationships to picklist values was something that we planned to support, but we don't have it and it isn't on the immediate roadmap. There are a number of reasons why we make you specify an Entity definition before you can specify a Field definition, but the simplest ...


2

You can make your life easier (in my opinion, of course; perceptions of readability may differ) by using string formatting to inject the dynamic elements of your query, rather than adding more concatenation. Note that you cannot use an Apex variable name (or a bind, for that matter) in the SELECT clause of your query; you must construct it yourself. String ...


2

The only context where we dynamically do anything with custom metadata type instances (records) is during installation of our managed package where we want to dynamically create unprotected instances that are equivalent to some previous configuration approach in an upgrade. In this context there's clearly no worry about seeing a deployment happen (nothing &...


2

If you can run Apex, here's how you assemble the list for the destructiveChanges.xml very quick. Note: replace { and } by corresponding angle brackets. Copy paste the debug statements into your destructiveChanges.xml file. List{String} objectTypes = new List{String}{ SomeCustomMetadataType__mdt.getSObjectType().getDescribe().getName(), ...


2

Assuming you have VS Code and your metadata in source control, it should be pretty easy to search against all the metadata in the IDE with whatever search term (custom metadata type, a field on that metadata type, etc). You can leverage files to include or files to exclude if you don't want profiles to display or are looking for references in specific files (...


2

The blue part is always present on a Lightning Tab's background. You can "fix" this with a bit of a negative margin. Aura .THIS { position: absolute; left: 0; right: 0; top: 0; bottom: 0; margin: -1em; } LWC :host() { position: absolute; left: 0; right: 0; top: 0; bottom: 0; margin: -1em; } You may ...


1

Just add casting to List<Object> before deserialization. Now you can iterate through your List. Deserializing inner-array of leads will be in the same way. List<Object> configs = (List<Object>) JSON.deserializeUntyped(jsonString); for (Object configObject : configs) { Map<String, Object> config = (Map<String, Object>) ...


1

Not sure why you would think List<SObject> records = SObject.getAll().values() would be supported Each CMDT is a separate SobjectType and to fetch the records given an SObjectType you can just use SObjectDescribe methods and dynamic SOQL (which does not burn any of your SOQL limits). It is also best practice to create a selector class that wraps your ...


1

in this case, you can replace get and set properties (as it is not possible to mock properties with Stub API) with the getter and the setter method, and you can mock them. private List<Configuration__mdt> configuration; private List<ConfigFields__mdt> configFields; public List<Configuration__mdt> getConfiguration(){ if(configuration == ...


1

Yes, but if you have some CI/CD in place, then this will get overridden by the data you have in your VCS. If you (or anyone else, or a CI/CD system like the above) uses the metadata API or a changeset to re-deploy the custom metadata record, changes you made in production will be overwritten.


1

Yes, it can be done without SOQL queries in Apex: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_custom_metadata_types.htm Example from documentation for your Metadata Type: LoginAPI__mdt mc = LoginAPI__mdt.getInstance('Login'); System.debug(mc.URL__c);


1

Unfortunately, you cannot refer custom metadata type in custom links. Custom metadata type can be referred only in Formulas, Default Values, and Validation Rules. Check more details here. Thanks


1

There are few settings around this:- Restrict access to custom metadata types Allow access only through granted permissions and when accessing custom metadata types in system mode, for example, from Apex. Read more here:- Control Read Access to Custom Metadata Types Protection and Privacy Options for Custom Metadata Types For sensitive data, like ...


1

It's late to do this in your case, but in general if you don't want custom field values to be overridden, make sure to select "Subscriber Controlled" as the Manageability for the field on the type. Upgrades never overwrite subscriber controlled fields on existing records aren't changed by package upgrades.


1

deployResult.details.componentSuccesses is a list of DeployMessages. Each DeployMessage has an id field, which is what you want.


1

You will need to write your retrieval process for the custom metadata in such a way it behaves predictably. If you retrieve the data and store it to a static variable, then interact with that variable in the same transaction, you would not pay the cost of retrieval and processing a second time. Generally, with custom metadata structures, these costs are ...


1

This might be a bug in the Source Tracking and you should raise a support ticket to make sure this is fixed for Custom Metadata records for the pull command for the exclude remote metadata changes case. use For a workaround, one simple technique is to create a different folder than your default force-app Like You can call it unpackaged and have the records ...


1

Packaged custom metadata type instances that are part of a managed package cannot be deleted, exactly like any other packaged metadata. The best you can do is update the content of that instance using the Apex Metadata API. Alternatively, don't package the instance and instead generate it in the installer (though this probably means you can't make it "...


1

If this field needs to remain writeable (or specific to the year in which it was created), then you can move these bands into Custom Metadata. If neither of those conditions apply, use a Formula Field instead. With metadata mappings, your code would look something like: List<Market_Segment__mdt> segments = [ SELECT Label__c, Minimum__c, Maximum__c, ...


1

We are using soql query to return custom meta data earlier. In Spring 21, we can access custom meta data without using soql Query. We can use the Apex getAll(), getInstance(recordId), getInstance(qualifiedApiName), and getInstance(developerName) methods to retrieve information from custom metadata type records faster. These methods don’t rely on the ...


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