Skip to main content

Hi All, 

 

I have been working on creating multiple users by uploading .csv file which contains all required user data, but when we are querying and inserting permissionSetAssignment record we are getting the below error -

 

"common.apex.runtime.impl.DmlExecutionException: Insert failed. First exception on row 5; first error: INVALID_CROSS_REFERENCE_KEY, You can't assign or unassign this permission set because it's associated with a profile.: []"|0xa786909 

We tried a few solutions such as  - 

1. Creating the PermissionSetAssignment record in future method

2. Splitting it into separate transactions 

 

But, even then we are getting the same error.

Can anyone please help in finding the reason 

2 answers
  1. Sushil Kumar (UKG) Forum Ambassador
    Jul 26, 2024, 12:39 PM

    @Anketha rao b s Every profile also has permission set record in the background. So if your query is pulling permission set which is linked to profile, this issue will come. Make sure to filter your permission set query using IsOwnedByProfile field. e.g. select id from permissionset where IsOwnedByProfile =false. 

0/9000