1

I apologise about the title. Couldn't phrase it well.

I have this page with lots of rows. Each row has an input field representing a value of a sObject. Once a user changes a value into a field I catch that with JS and using RemoteAction I sent the ID of the sObject and the value to update in the database. This leads to a lot of single queries, so not good.

How can I avoid this. Obviously if I was to put a save button then I could just gather all fields at once and send them as a list. However I want to avoid the usage of the save button.

Is there a way to store the information into a batch or something and execute that let's say in 5 minutes after it was first populated? This way I can give the user time to keep updating fields and then bulk update them.

11
  • 1
    One of the solutions would be to create some global variable, called queue, and the use set interval (w3schools.com/js/js_timing.asp) that would perform actual remote call with all the data from global variable, and then clean it
    – kurunve
    Commented Mar 1, 2016 at 15:53
  • What's the problem with ththe single queries? Not limits, I assume. Commented Mar 1, 2016 at 15:53
  • 2
    API limits are all incoming. Outbound API calls from SFDC do not count against the limit... I'd like to hear the OP's reasons Commented Mar 1, 2016 at 15:58
  • 2
    Why all the focus on JS instead of OOB?
    – Adrian Larson
    Commented Mar 1, 2016 at 16:09
  • 1
    "Remote Action". :D You have a limit of how many records can be selected/edited at the same time. Make sure to keep your SoQLs under it. ;) Commented Mar 1, 2016 at 18:04

1 Answer 1

2

Yes, Surely

Here is how you can do it.

1) Record all the updates in json
2) Write java script function that call action function and pass recorded json
3) Use setTimeout function to call the JS function created @ 2)

Some points to note:
1) If user close the browser your last batch of data can be lost
2) if user navigate to other page again data lost can happen
3) Have you check remote object as alternate solution

7
  • Why is setTimeout relevant? Can you please explain in more depth?
    – Adrian Larson
    Commented Mar 1, 2016 at 16:14
  • The setTimeout() method calls a function after a specified number of milliseconds. so you can chain /schedule / call recursively to invoke auction function automatically after 5 min. Its same like action poller but in JS. let me know if you have further questions. Commented Mar 1, 2016 at 16:27
  • I know what it does. What doesn't make sense is why you need it in this context, instead of just performing the action directly.
    – Adrian Larson
    Commented Mar 1, 2016 at 16:28
  • to call action function automatically after every 5 minutes as OP asked in question Commented Mar 1, 2016 at 16:29
  • 1
    also, you can not have more than 10 types of sObjects at once. You should take care of the number of types of records.
    – ipradhansk
    Commented Mar 1, 2016 at 18:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .