15

You could implement infinite scrolling similar to what I did for my custom Lightning Component that renders data table. In your main component's render.js file attach a listener to the window.onscroll event. As the user scrolls down the page the below code detects once the user has neared the bottom then can take action. In my example, I invoke helper....


14

As far as I can tell, Lightning components don't support that dynamic reference syntax. You could consider dynamically generating the content of this component with the component controller: Component <aura:component controller="GetAFewContacts"> <aura:attribute name="contacts" type="Contact[]" /> <aura:attribute name="fieldNames" ...


13

You're absolutely correct. The system basically gathers everything upfront. This allows the system to display the total number of batches before it starts processing the data. The "why" has to do with general limits: you can't query more than 50,000,000 rows, so it needs to know if you'll break that limit and abort early, and there's a daily limit, so the ...


9

I've never tried it, but I don't see anything in the System.abortJob documentation that says it doesn't work when called from the batchable so try: public void execute(Database.BatchableContext bc, List<SObject> scope) { try { ... } catch (Exception e) { // Report errors here System.abortJob(bc.getJobId()); } } I ...


9

Great question! You need to AuraEnable the properties in the wrapper class.


7

Please change <aura:attribute name="expenses" type="Sledgehammer.Expense__c" /> to <aura:attribute name="expenses" type="Sledgehammer.Expense__c[]" /> in your "form.cmp"


6

As you have mentioned you have only one element, that is why you are facing this problem. you are using; system.debug('skill is----------------->>>>>>' + iter.next().Name ); js.Skill__c=iter.next().Id; And each time you call iter.next() it will take you to the next element. So to avoid this you can use; while(iter.hasNext()){ Skill__c tempSkill ...


6

in your second iteration, use {!account.Contacts} instead of {!v.account.Contacts} <aura:iteration items="{!account.Contacts}" var="contact">


6

Just as addition to gNerbs answer: if you really need or want a own component you can use the iterator directive which has a first / last item attribute Like: <template> <template iterator:it={animals}> <c-child key={it.value.key} animal={it.value.value} is-last={it.last}></c-child> </template> </template&...


5

Pretty much all browsers support the JavaScript method Object.keys() which takes in an object and returns an array of just its keys. So you could have a second attribute of type String[] and set it in the controller equal to Object.keys(theMapYouWantToIterate). A bit more troublesome though is the fact that you can't actually look up that index of the map in ...


5

You need to call the DoInit handler. Rename your javascript from "getMyObjects" to "doInit." Component: <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> Controller: ({ doInit: function(cmp){ var action = cmp.get("c.getMyObjects"); action.setCallback(this, function(response){ var state = response.getState(); ...


5

So, this snippet should do it. (I am being more verbose than I need to, for clarity's sake) List<User> usersWithDupes = <your list here> Set<User> usersUnique = new Set<User>(); usersUnique.addAll(usersWithDupes); List<User> usersUniqueList = new List<User>(); usersUniqueList.addAll(usersUnique);


4

Just for reference, here is verified working code - it's very similar to that shown above, but I fixed a couple of issues: <aura:iteration items="{!v.objWrap}" var="item" indexVar="idx"> <aura:if isTrue="{!lessthan(idx,10)}"> <a href="javascript:void(0);" onclick="otherfunction()">{!item}</a> </aura:if> <aura:if ...


4

I was able to reproduce the issue with locker service enabled.Looks like a bug in LC. As a workaround, you could create new instance of the array and set it to alltests aura:attribute. So replace below line in the add method: c.set("v.alltests", alltests); By this line: c.set("v.alltests", [].concat(alltests)); So your add method will look like this: ...


4

It turns out that using an :if in an :iteration is not recommended. From the salesforce developer documentation: Here are some use cases where you should consider alternatives to <aura:if>: You need to nest conditional logic or use conditional logic in an iteration It is stated that this is for performance reasons, which echoes the warning ...


4

So you have a collection of users and you want to remove any with duplicate names? You could do that when building the first map using Map<string, Map<string, User>> where the inner string is the user name. E.g. public Map<String, User[]> allPeople { Map<String, Map<string, User>> departmentMap = new Map<String, Map<...


4

The overall answer to this is that there is an Apex Batch Handler which controls batch class execution. You could think of it like a method that calls your start method, then launches threads which call your execute method and handles the result of those threads, and finally calls your finish method once all execute threads have completed. With this in ...


4

A conceptual approach could be store the data you need as custom data-attributes in the <li> collect the data you need into a JavaScript object (I use jquery for DOM-operations like this - others here will crucify me for that) serialize the object into a JSON string pass the JSON string to another Apex method using an action in Apex deserialize the ...


4

Your exception is not being caught because FinalException is not catchable. Neither are LimitException nor AssertException. You can quickly check for yourself if a given type of exception is catchable using an anonymous script like the following: try { throw new FinalException(); } catch (Exception pokemon) { system.debug('Cannot catch em all'); } ...


3

If you look into documentation You can use list.clone() Example List<Skill_Review__c> results = [SELECT Id,Name,Skill__c,Level__c FROM Skill_Review__c where Interview__c =:review.id ]; List<Skill_Review__c> skillRev = results .clone(); Like @Ashwani said you can ...


3

With the introduction of chaining Queueable, and the ability to chain Queueable with callouts, we can daisy-chain multiple callouts efficiently without having to "guess" how many batches we need upfront from the Batchable interface. A simple implementation would look like: public class ChainedCallout implements Queueable, Database.AllowsCallouts { ...


3

It's about 2 years after I initially touched this issue and today I've found this Known Issue here https://success.salesforce.com/issues_view?id=a1p3A0000008gDzQAI It confirms my ancient observations from 2015 and confirms also that the Peters fine-grained approach does not work. For me the recommended workaround is not usefull, since ui:whatever can't ...


3

If it's just a contains check, then an additional, set holding all the ProductId values would be the simplest approach to avoiding the iteration over the AccountId values and would probably make the code a bit clearer too. The set could be generated from the complexMap using: Set<Id> productIds = new Set<Id>(); for (List<Map<Id, ...


3

I have also been running into the 'Number of iterations exceeded' limit. It seems to be the 'Maximum number of executed elements at runtime' limit that I am hitting (the limit is 2000, see the Salesforce documentation here: https://help.salesforce.com/apex/HTViewHelpDoc?id=vpm_admin_flow_limits.htm). The reason this limit is hit is that when looping ...


3

In addition to my previous answer here, the documentation says that you should not remove elements of a current collection: To remove elements while iterating a list, create a new list, then copy the elements you wish to keep. Alternatively, add the elements you wish to remove to a temporary list and remove them after you finish iterating the collection. ...


3

Note that there are two separate classes: Iterable and Iterator. In your question you use the latter where the interface demands the former. Note also that a List is an Iterable: Object demo = new List<String>(); system.assert(demo instanceof Iterable<String>); So you can just return the list. No need to define your own custom classes nor wrap ...


3

Yes, you're going to need two loops. That's the price you pay for having to parse a two-dimensional list. The trick is to put the record you're creating outside the inner loop. However, since you also have a header row (typically), you usually want to remove that one first. String[] headers = parsedCsvData.remove(0); Wholesale_Pipeline__c[] records = new ...


3

Store them in their own list of strings and then iterate over the list and you should achieve the result you're looking for <aura:attribute name="vehicles" type="String[]" default="['boat','car','trash truck']"/> <aura:iteration items="{!v.vehicles}" var="Field3"> <option value="{!Field3}">{!Field3}</option> </aura:iteration&...


3

You're on the right track, just missing some pieces to keep moving forward. You'll want to reference an apex controller which helps you with server side actions and surfaces the results to your lightning component. I am using the Account object in my example, in your case you would replace this with your custom object. Create a class(ie appController.apxc)...


3

Build your string in Javascript and just display it to the page as opposed to using the for:each template. @track animalString; @wire(getAnimals) assignAnimals(animals) { this.animals = animals; this.animalString = this.animals.join(', '); } Then: <span>{!animalString}</span> Or what ever element/component you want to use to display ...


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