New answers tagged

2

sobjList is a generic List<sObject>. The sObject class has no property Case__r, and Apex does not resolve properties like this at runtime. The easiest way to handle this is to declare the result as a List< Staging_order__c>, so that the result of get() is an actual Staging_order__c which has the requisite properties. You could also cast the ...


3

When You say I used a list to get the values of the custom metadata fields. First of all, You should consider that [SELECT A__c, B__c, C__c FROM CustomMetadata__mdt] SOQL returns you a list of CMT records, not fields. So if You want to get a concrete record of CMT you should specify filter conditions [SELECT A__c, B__c, C__c FROM CustomMetadata__mdt ...


3

To check the list empty value, You can use these methods from List class:- isEmpty() Returns true if the list has zero elements. Example:- !opportunitiesMap.get(actualTool.Rent__r.Opportunity__c).OpportunityInfo__r.isEmpty() size() Returns the number of elements in the list. Example:- List<Integer> myList = new List<Integer>(); Integer ...


0

Here is a code sample if you want to iterate through the Map to look for a specific value: for(String c : newCountries){ if(c == 'United States' && Countrymap.get(c) != 'English'){ //Throw error because language is not English } } As @BrianMiller mentioned there is a .contains() method on Set so here is a code sample if you want to create ...


0

The behavior you are describing seem specific to the one that happens after a contact has been deleted using the Contact Delete process. If you recently deleted some contacts, they are now in the Suppression period - the default length is 14 days, but it's possible that you used a different period. In that timeframe, contacts won't be visible in the UI, ...


0

You don't need a double For loop and you should avoid that pattern, it is very inefficient. A Map is a (key, value) set so you can only hold 1 Country to 1 Language pair, the 2nd UnitedStates pair (UnitedStates, Spanish) replaces the first (UnitedStates, English). Generally with a map you will want to iterate through a list of keys(Countries) and get the ...


1

I cleaned up your code a little bit to fix some Bulkifying pitfalls, but to David Reed's point we still need your Trigger code to help you out further: public class NaicsExclusion { public static void CompareCodes(Account[] accs) { List<NAICS_Exclusion__mdt> BadCodes = [SELECT Name__c FROM NAICS_Exclusion__mdt]; for(Account a :...


2

You can create a separate list to keep track of the cases associated to the budgets. This works because of the fact that objects are stored by "reference", meaning that an update to one object in memory affects all its references. Here's how you can do that: List<Case> allCaseList = new List<Case>(); List<Case> budgetCaseList = new List<...


1

There is an issue in the loop exit. In case if i equals arr.size() - 1, it will still not exit the loop, but rather try to access i+1 element of an arr array, and that would cause an exception. This is proper code public static List < Integer > getMovingSum(List < Integer > arr) { List < Integer > movingSumList = new List < ...


Top 50 recent answers are included