Description

In some cases, the ReferenceGen does not work as expected, and the CSVToMapGen can be used in the Foreign Key Attribute to reference a Primary Key. 


For instance, the following has been set up in a Project: 


ParentScenario

User - id (RangeQueryV2Gen)


ChildScenario

User

UserInfo - idNumber (ReferenceGen)

When this setup is present in a Project, the ChildScenario will query again because GenRocket is designed to execute the parent domain, then the child in the second Scenario. 


Since it uses RangeQueryV2Gen, it will query again and get the last value from the query instead of the first one. That’s why we don’t get the expected data when we reference it with the ReferenceGen Generator.


Solution Example

The User Domain will be the parent domain. It holds an id Attribute that will generate the Primary Key within a CSV file.



A UserInformation Domain has also been created. It holds a userId Attribute as a foreign key. 



This will leverage CSVToMapGen Generator to populate the foreign key generated in a CSV file format. 

  • fileName = User.txt (This is the delimited file generated by the User Domain.)
  • columnName = id (CSVToMapGen will read the id value into memory from the CSV file).



Below is the relationship between UserInformation and User.



Make sure that in the UserInformationScenario, you assign a one-to-one relationship. As shown in the image below, 1 UserInformation will be generated for each User. This can be achieved by changing the Domain loopCount.



The DelimitedFileV2Receiver needs to be added to the User Domain. This will generate a 'User.txt' file with the required id, username, and password values.



The User Domain will generate the User.txt file, which should look as shown below. The id value is the Primary Key. 


This will be the same number that will be generated in the userId attribute of the UserInformation Domain.



You’re all set!

The output should look like this.