New answers tagged

0

You can't put 'existingAccountResult into a List<Account> - you need to turn it into an account first. For example: Account exResult= new Account(); exREsult.Id = c.accountId; exResult.status = c.account.Status__c; exResult.includeinfunnel = c.account.Include_in_Funnel__c; Then you can add exResult into your list.


3

Instead of new Map<String,String>(){'January'=>'01'}; Use new Map<String, String>{'January'=>'01'}; Apex Developer Guide Maps As with lists, you can populate map key-value pairs when the map is declared by using curly brace {} syntax. Within the curly braces, specify the key first, then specify the value for that key using =>.


0

create a map of opportunity id as a key and set of opportunity ids i.e : Map<Id, Set<Id>> Use that map keys(accountids) in SOQL Create a map which is store field values with opportunityid i.e Map<Id,String> for your third soql


3

One of the approaches could be to use Map<Id, Set<Id>> structure in order to collect all data. Consider following example: Map<Id, Set<Id>> opportunity_ids_by_account_ids = new Map<Id, Set<Id>>(); for(Opportunity opp: [Select Id, AccountId From Opportunity Where Id IN :SetIds]){ if (!opportunity_ids_by_account_ids....


1

If your Key in Map is same for all the records, it will overwrite the existing records in the Map with the same Key. In your case the Key for all 3 records is 1 that is the reason, it is showing the latest record in the Map in your final debug. You can go through the documentation of Map for further information. Excerpt from the above mentioned ...


3

Since StartDate__c is not unique, then you have one of two choices: Use a unique key (Id, or other field) Change your map to handle many records per one key Since you seemed to suggest that doing #1 led to CPU time limits, I'd suggest changing your map to hold a list of Gear or Tool objects. Example for tool below assuming that StartDate and your EndDate ...


1

Hello, The problem IS the structure. Let's analyze your code. You have a test class called : FLLC_Foreman_Job_Packet_Helper_Test In this class you have a method called getPhotoNotesFieldMapTest and I suppose it's a test method so you should have @test also on it. (Point of attention 1) you have your return statement before the assert ==> the assert will ...


2

Nothing can be written after return statement. Methods with @IsTest annotation should be void. What I suggest you to do. Move method getPhotoNotesFieldMap to the separate class, remove Test from method name. In your test class set ethod: @IsTest static void getPhotoNotesFieldMapTest() { Map<String, String> toCheck = YourNewClass....


0

Loop Through the Array of JSON using forEach() I used hasOwnProperty() to check the property in Object Use the condition operator to check the key present in an object(output). Below is the code I changed, Please see codepen let finalMap=[{"key":"OTC","subprocessName":"CXO","weightage":50}, {"key":"OTC","subprocessName":"Order Management","weightage":50},...


0

Are there any workflows, process builders, or triggers on the update of Deal__c records? You mentioned there's 10,000 records pulled in that query. You could look at having your scheduled class call a batchable apex class and control the batches to process a smaller amount of records at a time. https://developer.salesforce.com/docs/atlas.en-us.apexcode....


1

Pass the empty map as a parameter and check if map.isEmpty() Map documentaion class c{ static void method(List<String> lstStr, Boolean bool, Map<integer,string> testMap){ if(!testMap.isEmpty()){ //logic } else{ } } } class B { //pass the empty map in method c.method(lstStr,true,new Map<integer,string>());...


3

A better approach would be to overload methods. You can create 2 methods with different parameters for your use case as below: public class classC { public static Object meth1(List<String> lstStr, Boolean bool, Map<integer,string> testMap) { // logic } public static Object meth1(List<String> lstStr, Boolean bool) { ...


2

I don't see anyplace in your code where you're validating that the Dates of all related CompanyOrder__c have StartDates and EndDates that do not overlap with one another. That would require a query for all CompanyOrder__c's related to the parent Opportunity, then iterating through the StartDates and EndDates since not all instances of them will necessarily ...


0

Below is the code snippet const data = ["Vendor Master", "Vendor Master", "Customer Master", "Customer Master", "Customer Master", "Customer Master", "Material Master", "Material Master", "Material Master", "Vendor Master"]; function count(arr) { return arr.reduce((prev, curr) = > (prev[curr] = ++prev[curr] || 1, prev), {}) } console.log(count(data))...


1

I keep the count occurrence in the object, so you can set this object in component with object type attribute. <aura:attribute name="xyz" type= 'Object'/> let count = {}; ["Vendor Master","Vendor Master","Customer Master","Customer Master","Customer Master","Customer Master","Material Master","Material Master","Material Master","Vendor Master"]....


3

I think that there are 2 parts to your question. First is the actual how to part. It seems like you don't really understand the data structures provided by SFDC. The second is architectural, Your code has me concerned that the architecture behind what you're trying to do is not optimal. I'm going to focus on the first part. If you have architectural ...


Top 50 recent answers are included