This page contains three examples of how to configure the Generation spreadsheet in the domain of Sample Commerce.
Order Date Example
This example shows how to Configure the Generation spreadsheet to generate Order Dates.
If we look at the Order tab, we will see a set of records such as the following:
If we look at the OrderDate row, we see that that there is a FunctionParameter containing RandomHelper.Faker.Data.Past(0). To understand this parameter, we can remove it and type into the cell =VIP which will initiate the auto-completion facility for the parameter value. Once we start typing =VIP.Date.Past, the first item on the completion list will be VIP.Data.Past(yearsToGoBack). Once we see that, we understand that the parameter for this function should be 0 if we want to use the current year's data. So the full parameter should be VIP.Data.Past(0).
Order Number Example:
This example shows how to Configure the Generation spreadsheet to generate Order Numbers.
If we look at the second row of the Order table, we see the following value in FunctionParameters OrderNumber:
The '??' stands for alphabetic characters and '###' stands for numbers.
The string VIP-??### represents an order number.
Customer Id Example:
This example shows how to Configure the Generation spreadsheet to generate Customer Ids which are referenced by Orders.
If we look at line 4 above, the CustomerID, contains the FunctionParameter value of var_Customer_id. To understand how this works, we must look at the Mapping* table in this sheet which looks like this:
The display above tells us:
Each Order must have a Customer. (Order is a Child of Parent Customer)
When an Order is created, there is already a Customer for that Order in the DB, so that the Customer_Id can be referenced when an order is placed.
*It is not essential to create a Mapping table, but it is very useful and recommended to maintain referential integrity in the database.
In the example database model shown in this article, an Order can reference a Customer and a Product can reference a Supplier, but a Product cannot reference a Customer or an Order. Likewise, an OrderItem can reference an Order, but an Order cannot be referenced by a Product.
So, in this example, the CustomerID must be assigned before the Order is created, so that we have access to this value.