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
Keith PatellaKeith Patella 

Apex Managed Sharing with Users that don't have permission

I have a lightning component that is used to automate Apex Managed Sharing on our custom objects. The controller that the lightning component calls and any other apex class that is referenced does not have "without sharing" defined. The problem is the user is still not allowed to change anything with the apex sharing object and I'm getting the following when trying to recreate the information. I've read in many places that my apex code should be running in "System Mode" so I can't figure out why we're getting this error even though the user does not have "Modify All Data" permission enabled.

Line 2024: 15:06:37.0 (480072354)|USER_DEBUG|[25]|INFO|@@@@ Manual Share Deleting 6 objects
    Line 2057: 15:06:37.0 (501762950)|USER_DEBUG|[25]|INFO|@@@@ Manual Share Delete failed with error of insufficient access rights on object id
    Line 2080: 15:06:37.0 (502077538)|USER_DEBUG|[25]|INFO|@@@@ Manual Share Delete failed with error of insufficient access rights on object id
    Line 2103: 15:06:37.0 (502347060)|USER_DEBUG|[25]|INFO|@@@@ Manual Share Delete failed with error of insufficient access rights on object id
    Line 2126: 15:06:37.0 (502614504)|USER_DEBUG|[25]|INFO|@@@@ Manual Share Delete failed with error of insufficient access rights on object id
    Line 2149: 15:06:37.0 (502888465)|USER_DEBUG|[25]|INFO|@@@@ Manual Share Delete failed with error of insufficient access rights on object id
    Line 2172: 15:06:37.0 (503167671)|USER_DEBUG|[25]|INFO|@@@@ Manual Share Delete failed with error of insufficient access rights on object id
    Line 2414: 15:06:37.0 (506037542)|USER_DEBUG|[25]|INFO|@@@@ Manual Share Inserting 12 objects
    Line 2446: 15:06:37.0 (514618945)|USER_DEBUG|[25]|INFO|@@@@ Insert failed with error of invalid row cause
    Line 2469: 15:06:37.0 (514999746)|USER_DEBUG|[25]|INFO|@@@@ Insert failed with error of invalid row cause
    Line 2492: 15:06:37.0 (515396674)|USER_DEBUG|[25]|INFO|@@@@ Insert failed with error of invalid row cause
    Line 2515: 15:06:37.0 (515790526)|USER_DEBUG|[25]|INFO|@@@@ Insert failed with error of invalid row cause
    Line 2538: 15:06:37.0 (516183906)|USER_DEBUG|[25]|INFO|@@@@ Insert failed with error of invalid row cause
    Line 2561: 15:06:37.0 (516583554)|USER_DEBUG|[25]|INFO|@@@@ Insert failed with error of invalid row cause
    Line 2584: 15:06:37.0 (517032424)|USER_DEBUG|[25]|INFO|@@@@ Insert failed with error of invalid row cause
    Line 2607: 15:06:37.0 (517461139)|USER_DEBUG|[25]|INFO|@@@@ Insert failed with error of invalid row cause
    Line 2630: 15:06:37.0 (517884833)|USER_DEBUG|[25]|INFO|@@@@ Insert failed with error of invalid row cause
    Line 2653: 15:06:37.0 (518296367)|USER_DEBUG|[25]|INFO|@@@@ Insert failed with error of invalid row cause
    Line 2676: 15:06:37.0 (518721551)|USER_DEBUG|[25]|INFO|@@@@ Insert failed with error of invalid row cause
    Line 2699: 15:06:37.0 (519123861)|USER_DEBUG|[25]|INFO|@@@@ Insert failed with error of invalid row cause

If it's not possible to have this user update the object I'm looking for suggestions on how to get the data updated when the user modifies the Account Team without me turning on Modify All Data. The best suggestion I've read about so far is to use the Salesforce REst API as another user to make the modification.

The route I originally took was to set a dirty flag and was then going to use a Scheduled class but these classes can only be scheduled weekly and I would want something that would work at least daily.