Mark specific update entries in a Visualforce table

I created a search page that returns set records using a custom controller and a Visualforce page. Users can update specific fields in individual records.

I want to be able to save all changed records at the same time, but the action command updates the entire set of returned values, not just the changed records. The application requires updating only the changed records.

With the exception of filtering for all possible changes that can be made to a record, or to add a save button to each record, someone has a creative idea on how to identify certain records that have been changed, so the application can save only those that have been edited?

+3
source share
1 answer

Very interesting question :)

On SFSE, there is a wonderful answer about tracking changes between old and new through any field description or JSON serialization: Common fields of sObject fields . Please note that I am related to the answer that I find most neat, consider reading the entire page!

This question is also interesting because it would put your logic in a more correct place - in the trigger. Because you have to ask yourself if itโ€™s normal to make an update that doesnโ€™t really change anything on your search page - should it be possible on other pages as well?


If this is not what works for you here is another interesting trick.

( , ). , :

Set<User> users = new Set<User>();

User u1 = new User(Id = UserInfo.getUserId());
User u2 = new User(Id = UserInfo.getUserId(), LastName = 'Doe');

users.add(u1);
users.add(u2);

System.assert(users.contains(u2));

u2.FirstName = 'John';

System.assert(users.contains(u2), users); // boom, headshot. It was there a minute ago, I swear!

, Map<Id, sObject> , //- . - .

():

  • , .
  • none/some/all "submit".
  • Set<sObject> ( addAll).
  • . , .
  • mySet.removeAll(originals); - .
  • .

, , - - # 4 ... , ( List.deepClone) - !

( - - , removeAll equals . , )

+1

All Articles