3

I am trying to create some test data with snowfakery. I am creating users with the snowfakery recipe below.

I am creating 1 user, then another user as a 'friend' so I can set the manager field on the second user with the first user.

The problem is I am getting an 'Invalid assignee' error on the Insert PermissionSetAssignment step

[12/08/21 18:17:58] Beginning task: LoadData                                                                                                                                                          
                    As user: [email protected]                                                                                                                                            
                    In org: 00D2F000000K3vQ                                                                                                                                                           
                                                                                                                                                                                                      
[12/08/21 18:18:15] Running step: Insert PermissionSetAssignment                                                                                                                                      
[12/08/21 18:18:16] Prepared 2 rows for DataOperationType.INSERT to PermissionSetAssignment.                                                                                                          

Error: Error on record with id 1: INVALID_CROSS_REFERENCE_KEY: Invalid assignee ID: {0}. ()

Is there something wrong with the recipe?

I've tried using nicknames but that does not seem to help.


- plugin: snowfakery.standard_plugins.Salesforce
- plugin: snowfakery.standard_plugins.Salesforce.SalesforceQuery

- macro: userdata
 fields:
   Alias: 
     fake: alias
   FirstName: 
     fake: firstname
   LastName: 
     fake: lastname
   Username: ${{firstname}}${{random_number(1000, 100000)}}@${{random_number(1000, 10000)}}fake.claritycx1.com
   Email: ${{Username}}
   TimeZoneSidKey: America/Bogota
   LocaleSidKey: en_US
   EmailEncodingKey: UTF-8
   LanguageLocaleKey: en_US
   ProfileId:
     Salesforce.ProfileId: Standard User

- object: User
 nickname: manager
 include: userdata
 friends:
   - object: PermissionSetAssignment
     fields:
       AssigneeId:
         reference: User
       PermissionSetId:
         SalesforceQuery.find_record:
           from: PermissionSet
           where: Name='KAM_Manager'

   - object: User
     include: userdata
     fields:
       ManagerId:
         reference: manager

     friends:
       - object: PermissionSetAssignment
         fields:
           AssigneeId:
             reference: User
           PermissionSetId:
             SalesforceQuery.find_record:
               from: PermissionSet
               where: Name='KAM'

1 Answer 1

2

Answered over on the CumulusCI group in trailhead by Paul Prescod (Salesforce.org)

Snowfakery and CCI need to infer in what order to load data based on relationships between records. Your particular data model confused it because of the recursive User sobject references.

I've added code to recognize situations like this for an upcoming Snowfakery release, but in the meantime you can control the load order by making a load file with the following contents:

 - sf_object: PermissionSetAssignment
   load_after: User

The load file is described here:

https://cumulusci.readthedocs.io/en/stable/data.html?highlight=load.yml

Under the heading "Controlling the load process"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .