The following code shows assignment of properties and creation of a new tenant. The service's NewTenant( ) factory method expects the name of the tenant. The Type, DefaultAllocation, and each of the Default*Area properties are all mandatory properties that need to be specified before the tenant can be passed to the CreateTenantGroup( ) service method. The Default*Area properties are all defined as instances of IArea, which must be known to, and can be retrieved from, the service. This example sets the default allocation to "Immediate" in order to allocate the partitions according to the default areas when the tenant is created:
define variable tenant as ITenant no-undo.
assign
tenant = service:NewTenant("Acme")
tenant:Type = "Regular"
tenant:DefaultAllocation = "Immediate"
tenant:Description = "This company is an important player in its segment.")
tenant:DefaultDataArea = service:GetArea("FirstClassDataArea")
tenant:DefaultIndexArea = service:GetArea("FirstClassIndexArea")
tenant:DefaultLobArea = service:GetArea("GeneralLobArea").
service:CreateTenant(tenant).
All writeable properties except Type can be edited after the tenant is created. The following code edits two of the properties on an existing tenant. Note that IsDataEnabled defaults to TRUE when the tenant is created:
assign
tenant = service:GetTenant("Acme")
tenant:Description = tenant:Description + " But is not ready to go online")
tenant: IsDataEnabled = false.
service:UpdateTenant(tenant).
Note: There must be at least one domain configured for a tenant with at least one user in order to login and access tenant data. The next section discusses how to add domains to the tenant.