I am facing trouble while inserting
1 share record
. When I am loggin to Admin Profile
, it is working fine without any DML exception
, but when I am login to Sales profile
, then I am facing such exception.
I checked with DescriveSObject
isCreatable
() method, I can see that Sales profile has create access on Package_Share__c
object.
This is the list I am inserting:
packageShareInsertList : (Package__Share:{UserOrGroupId=00540000000zHI5AAM, ParentId=a1I560000004iRIEAY, RowCause=PKG_Sales_Team__c, AccessLevel=Edit})
This is th DML Exception I am facing:
04:21:17.791 (3215279840)|FATAL_ERROR|System.AssertException:
Assertion Failed: System.DmlException: Insert failed. First exception
on row 0; first error: INVALID_FIELD_FOR_INSERT_UPDATE, invalid row
cause: []:
But Row cause
has valid value that I am sure. If it was a wrong value, then other profiles
would have thrown the same issue.
Please advise.
Best Answer
I believe you are having the issues because the user you are trying does not have "Modify all data" permission.
According to the documentation LINK
I came across another answer where this was successfully achieved via changing class's sharing model as "without sharing". Please try doing that as well.
Link to the Answer
EDIT
I believe you received error using with sharing because a user requires at-least read access to the record for which the share is to be created. LINK