Hot answers tagged

4

As I've said ... at ... least ... four times, just because you have a for loop inside another for loop, does not automatically make this a Bad Thing. Feel free to read the answers for more information. There are some minor optimizations that could improve performance, such as not calling the Map.get method more than once per loop, sorting before putting them ...


3

The above code has correct syntax provided boatData is an array. It looks like the Javascript object you have boatData is not an Array and hence you get an exception that .map is not a function. You can easily reproduce this with below Javascript code let object_x = {}; object_x.map( x => { return x; }); This will result in an error Error: object_x....


3

Consider mapping all your WorkOrders/Wrappers by a combination key (i.e UniqueKey__c + '.'+ Work_Order_Sequence__c.leftPad(10, '0') ). sort your combo key list comboKey = new List(mapWO.keyset()); combokey.sort(); iterate through sorted combokey and create a new list of WorkOrders/Wrappers. LIST<WO> wo = new LIST<WO>(); for (string k : ...


3

Maps are unordered collections, and may be organized in any order. Note that Iteration Order for Maps and Sets Is Now Predictable causes the values to be displayed in a consistent order, which is why they appear to be ordered alphabetically. If you want the order to definitely be preserved, return the keys in the order you would like. public class ...


1

In that snippet you're looping through the Set's elements. You could take a look at documentation about for loops. for (variable : list_or_set) { code_block } When executing this type of for loop, the Apex runtime engine assigns variable to each element in list_or_set, and runs the code_block for each value. By the way, I would suggest to always ...


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