Description
The SFQueryEachLoopGen Generator queries a column of data from a Salesforce Object on each iteration. The query takes place in realtime via a Salesforce REST web service call.
NOTE: Any time data is queried on each iteration in real , it will result in slower test data generation. An SFQueryGen Generator is also available and can be used for improved performance.
In This Article
- When should the SFQueryEachLoopGen be used?
- When should the SFQueryEachLoopGen not be used?
- How does SFQueryEachLoopGen work?
- Generator Parameters
- Use Case - Query an Account Object for the Account Name
When should the SFQueryEachLoopGen be used?
- Any time a set of column data needs to be queried from a Salesforce Object on each iteration and blended with synthetic data.
When should the SFQueryEachLoopGen not be used?
- Any time data needs to be queried from a source other than a Salesforce Object.
How does SFQueryEachLoopGen work?
- Uses a provided Query Statement to query any column of data from a Salesforce Object on each iteration via REST web services when the Scenario is run.
Generator Parameters
The following parameters may be configured for the SFQueryEachLoopGen Generator. Items with an asterisk* are required.
- serviceVersion* - Defines the Service URL version number. The current default is 34.0 and can be changed if needed.
- grVar1 - Defines the first optional variable that can take the place of a constant in the SOQL statement.
- grVar2 - Defines the second optional variable that can take the place of a constant in the SOQL statement.
- grVar3 - Defines the third optional variable that can take the place of a constant in the SOQL statement.
- grVar4 - Defines the fourth optional variable that can take the place of a constant in the SOQL statement.
- grVar5 - Defines the fifth optional variable that can take the place of a constant in the SOQL statement.
- query* - Defines the SOQL statement that will be executed to retrieve a column of data.
- list - Stores one value on each line in the list. To add values, type in the value and then hit ENTER on the keyboard. Note that the listed value shown is only for simulation mode; when running a true Scenario, the data will be loaded from the specified resource.
- defaultValue - Defines the default value to use if the query does not return a value.
Use Case - Query an Account Object for the Account Name
This use case shows how the SFQueryEachLoopGen Generator can query a Salesforce Account Object on each iteration for the account name.
Step 1 - Create a Project with a Domain
For this example, a Project titled 'SalesforceDemo' has been created with the default Project Version and an 'Account' Domain.
NOTE: Click here to learn about creating Projects. Click here to learn about creating/importing Domains into GenRocket.
Step 2 - Create an Attribute for Querying the Salesforce Object
For this example, an 'accountName' Attribute has been created for the 'Account' Domain.
NOTE: Click here to learn more about creating new Attributes for a Domain.
Step 3 - Assign the SFQueryEachLoopGen Generator to the Attribute
The data warehouse will automatically assign a Generator when an Attribute is created. In this case, the NameGen Generator was assigned and will need to be replaced with the SFQueryEachLoopGen Generator.
This can be done by completing the following steps:
- Enter SFQueryEachLoopGen into the Quick Replacement menu.
- Click the Replace button once finished.
Step 4 - Configure the SFQueryEachLoopGen Generator Parameters
For this example, two Generator parameters have been modified:
- grVar1 = Name
- query = select grVar1from account order by id
- defaultValue = None (if no values are returned from the query)
Step 5 - Save the Generator Changes
Click Save Generator after making changes to Generator parameters.
NOTE: Clicking Save Generator again will re-run the query.