function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
michaelforcemichaelforce 

Records in Recent Items after DML Rollback

I scoured the message boards and don't see anyone else who has run into this.  I'm thinking it's a bug, although not a terribly detrimental one.

 

I have a "without sharing" class that needs to know if the current user has access to a list of records.  So it uses a separate "with sharing" class to figure it out... works well.  Then to take it one step further and see if they have access to edit you have to get creative, and the knowledge in this forum told me the only way is to attempt an update, see which records failed and then do a rollback to a savepoint... this too works well, woohoo.

 

The weird thing, is that the records that are updated in this check will then show up in the users recent items.  I could see how maybe this is a good thing if the records were actually updated... but they weren't the change was rolled back.  I guess it's a bug.. thoughts?

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox

To test "edit" access, you may be able to use UserRecordAccess, available starting in version 24.0 API. It avoids the whole mess of having to perform a ghost update.

All Answers

Manos SpanoudakisManos Spanoudakis
would be interesting to check the last modified date and last modified by. Do they match with the time and user who did the rolled back update ?
michaelforcemichaelforce

Good question, I just checked and the last modified is NOT being updated... so it confirms the rollback is indeed working correctly.

Manos SpanoudakisManos Spanoudakis
well then I would vote for the undocumented feature ;-)
sfdcfoxsfdcfox

To test "edit" access, you may be able to use UserRecordAccess, available starting in version 24.0 API. It avoids the whole mess of having to perform a ghost update.

This was selected as the best answer
michaelforcemichaelforce

You rock!  I totally missed this awesome new object when it came out... nice one.

 

For anyone else stumbling upon this thread, here is a link to the API docs where they explain the UserRecordAccess object.

 

Andy S.Andy S.

I've just encountered the same issue.  Unfortunately the workaround won't help me, as I'm not doing an insert to test CRUD access.  Have a case open with Support.  Hopefully it will be viewed as a bug, as my users are going to be very upset if I wipe their Recent Items list.  (I'm updating >10 records, so the list is effectively cleared.)