• SummerRain
  • 0 Points
  • Member since 2009

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 2

Hi All


I have written a trigger as below

trigger testChangeOwnerTrigger on Case (before insert) { for(Case newCase : Trigger.New){ newCase.OwnerId ='005R0000000IufqIAC'; } }


Here the 'created use'r and 'new owner user' has the same profile.


This trigger is working correctly when I create case with System Administrator profile user, but when create case with other profile user then it throw an error "Insufficient Privileges You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary. Click here to return to the previous page "


I checked the profile & it has all data modification permissions.


Any idea?





Good morning,
I wrote a testMethod, in which I use a runAs user, like:
                Profile pr2 = [select id from profile where name='Standard User'];
                User u = new User(Manager=OTHERTESTUSER,alias = 'standt', email='standarduser@testorg.com',emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',localesidkey='en_US', profileid = pr2.Id,timezonesidkey='America/Los_Angeles', username='standarduser@testorg.com');


I want to set an other TestUser as the Manager of RunAs User....is that possible ?
I have attempted to create and insert a new User before the System.runAs statement, but that works somehow not..hmm.
Thanks a lot in advance for help!