Child pages
  • Relation

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
{hidden} DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY, UNLESS YOU KNOW WHAT YOU'RE DOING. THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO EXTRACT CHANGES FROM THE PAGE AND MERGE THEM BACK INTO SERVOY SOURCE{hidden} {sub-section:description|text=}{sub-section}\\{table:class=servoy sSummery}{colgroup}{column:width=80px}{column}{column}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=2}Property Summary{th}{tr}{tbody}{tr}{td}[Boolean]{td}{td}[#allowCreationRelatedRecords] Flag that tells if related records can be created through this relation.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#allowParentDeleteWhenHavingRelatedRecords] Flag that tells if the parent record can be deleted while it has related records.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#deleteRelatedRecords] Flag that tells if related records should be deleted or not when a parent record is deleted.{td}{tr}{tbody}{tbody}{tr}{td}[String]{td}{td}[#foreignTable] Qualified name of the foreign data source.{td}{tr}{tbody}{tbody}{tr}{td}[String]{td}{td}[#initialSort] A String which specified a set of sort options for the initial sorting of data retrieved through this relation.{td}{tr}{tbody}{tbody}{tr}{td}[Number]{td}{td}[#joinType] The join type that is performed between the primary table and the foreign table.{td}{tr}{tbody}{tbody}{tr}{td}[String]{td}{td}[#name] The name of the relation.{td}{tr}{tbody}{tbody}{tr}{td}[String]{td}{td}[#primaryTable] Qualified name of the primary data source.{td}{tr}{tbody}{table}\\{table:class=servoy sDetail}{colgroup}{column:width=100%}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Property Details{th}{tr}{tbody:id=C3794647-0246-4138-87A3-7013CC379872}{tr:id=name}{td}h6.allowCreationRelatedRecords{td}{tr}{tr:id=des}{td}{sub-section:C3794647-0246-4138-87A3-7013CC379872_des|text=|trigger=button}{sub-section}{sub-section:C3794647-0246-4138-87A3-7013CC379872_des|trigger=none|class=sIndent}Flag that tells if related records can be created through this relation. The default value of this flag is "false".{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:C3794647-0246-4138-87A3-7013CC379872_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:C3794647-0246-4138-87A3-7013CC379872_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:C3794647-0246-4138-87A3-7013CC379872_ret|text=|trigger=button}{sub-section}{sub-section:C3794647-0246-4138-87A3-7013CC379872_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:C3794647-0246-4138-87A3-7013CC379872_see|text=|trigger=button}{sub-section}{sub-section:C3794647-0246-4138-87A3-7013CC379872_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:C3794647-0246-4138-87A3-7013CC379872_see|text=|trigger=button}{sub-section}{sub-section:C3794647-0246-4138-87A3-7013CC379872_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=sam}{td}*Sample*\\{sub-section:C3794647-0246-4138-87A3-7013CC379872_sam|text=|trigger=button}{sub-section}{sub-section:C3794647-0246-4138-87A3-7013CC379872_sam|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=B229C522-A46E-4194-B637-8E19EC0F708D}{tr:id=name}{td}h6.allowParentDeleteWhenHavingRelatedRecords{td}{tr}{tr:id=des}{td}{sub-section:B229C522-A46E-4194-B637-8E19EC0F708D_des|text=|trigger=button}{sub-section}{sub-section:B229C522-A46E-4194-B637-8E19EC0F708D_des|trigger=none|class=sIndent}Flag that tells if the parent record can be deleted while it has related records. The default value of this flag is "true".{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:B229C522-A46E-4194-B637-8E19EC0F708D_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:B229C522-A46E-4194-B637-8E19EC0F708D_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:B229C522-A46E-4194-B637-8E19EC0F708D_ret|text=|trigger=button}{sub-section}{sub-section:B229C522-A46E-4194-B637-8E19EC0F708D_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:B229C522-A46E-4194-B637-8E19EC0F708D_see|text=|trigger=button}{sub-section}{sub-section:B229C522-A46E-4194-B637-8E19EC0F708D_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:B229C522-A46E-4194-B637-8E19EC0F708D_see|text=|trigger=button}{sub-section}{sub-section:B229C522-A46E-4194-B637-8E19EC0F708D_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=sam}{td}*Sample*\\{sub-section:B229C522-A46E-4194-B637-8E19EC0F708D_sam|text=|trigger=button}{sub-section}{sub-section:B229C522-A46E-4194-B637-8E19EC0F708D_sam|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=467EAE5F-B347-4072-98FD-0EEFD1626FED}{tr:id=name}{td}h6.deleteRelatedRecords{td}{tr}{tr:id=des}{td}{sub-section:467EAE5F-B347-4072-98FD-0EEFD1626FED_des|text=|trigger=button}{sub-section}{sub-section:467EAE5F-B347-4072-98FD-0EEFD1626FED_des|trigger=none|class=sIndent}Flag that tells if related records should be deleted or not when a parent record is deleted. The default value of this flag is "false".{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:467EAE5F-B347-4072-98FD-0EEFD1626FED_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:467EAE5F-B347-4072-98FD-0EEFD1626FED_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:467EAE5F-B347-4072-98FD-0EEFD1626FED_ret|text=|trigger=button}{sub-section}{sub-section:467EAE5F-B347-4072-98FD-0EEFD1626FED_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:467EAE5F-B347-4072-98FD-0EEFD1626FED_see|text=|trigger=button}{sub-section}{sub-section:467EAE5F-B347-4072-98FD-0EEFD1626FED_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:467EAE5F-B347-4072-98FD-0EEFD1626FED_see|text=|trigger=button}{sub-section}{sub-section:467EAE5F-B347-4072-98FD-0EEFD1626FED_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=sam}{td}*Sample*\\{sub-section:467EAE5F-B347-4072-98FD-0EEFD1626FED_sam|text=|trigger=button}{sub-section}{sub-section:467EAE5F-B347-4072-98FD-0EEFD1626FED_sam|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=1BACBFB5-BA87-449E-96D9-AB247F940A68}{tr:id=name}{td}h6.foreignTable{td}{tr}{tr:id=des}{td}{sub-section:1BACBFB5-BA87-449E-96D9-AB247F940A68_des|text=|trigger=button}{sub-section}{sub-section:1BACBFB5-BA87-449E-96D9-AB247F940A68_des|trigger=none|class=sIndent}Qualified name of the foreign data source. Contains both the name of the foreign server and the name of the foreign table.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:1BACBFB5-BA87-449E-96D9-AB247F940A68_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:1BACBFB5-BA87-449E-96D9-AB247F940A68_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:1BACBFB5-BA87-449E-96D9-AB247F940A68_ret|text=|trigger=button}{sub-section}{sub-section:1BACBFB5-BA87-449E-96D9-AB247F940A68_ret|trigger=none|class=sIndent}[String]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:1BACBFB5-BA87-449E-96D9-AB247F940A68_see|text=|trigger=button}{sub-section}{sub-section:1BACBFB5-BA87-449E-96D9-AB247F940A68_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:1BACBFB5-BA87-449E-96D9-AB247F940A68_see|text=|trigger=button}{sub-section}{sub-section:1BACBFB5-BA87-449E-96D9-AB247F940A68_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=sam}{td}*Sample*\\{sub-section:1BACBFB5-BA87-449E-96D9-AB247F940A68_sam|text=|trigger=button}{sub-section}{sub-section:1BACBFB5-BA87-449E-96D9-AB247F940A68_sam|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=47461253-6518-47C5-A46D-4BE321B76D81}{tr:id=name}{td}h6.initialSort{td}{tr}{tr:id=des}{td}{sub-section:47461253-6518-47C5-A46D-4BE321B76D81_des|text=|trigger=button}{sub-section}{sub-section:47461253-6518-47C5-A46D-4BE321B76D81_des|trigger=none|class=sIndent}A String which specified a set of sort options for the initial sorting of data retrieved through this relation. Has the form "column_name asc, another_column_name desc, ...".{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:47461253-6518-47C5-A46D-4BE321B76D81_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:47461253-6518-47C5-A46D-4BE321B76D81_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:47461253-6518-47C5-A46D-4BE321B76D81_ret|text=|trigger=button}{sub-section}{sub-section:47461253-6518-47C5-A46D-4BE321B76D81_ret|trigger=none|class=sIndent}[String]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:47461253-6518-47C5-A46D-4BE321B76D81_see|text=|trigger=button}{sub-section}{sub-section:47461253-6518-47C5-A46D-4BE321B76D81_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:47461253-6518-47C5-A46D-4BE321B76D81_see|text=|trigger=button}{sub-section}{sub-section:47461253-6518-47C5-A46D-4BE321B76D81_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=sam}{td}*Sample*\\{sub-section:47461253-6518-47C5-A46D-4BE321B76D81_sam|text=|trigger=button}{sub-section}{sub-section:47461253-6518-47C5-A46D-4BE321B76D81_sam|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=D3ECFE43-D079-4427-8C48-157BD4C55F4C}{tr:id=name}{td}h6.joinType{td}{tr}{tr:id=des}{td}{sub-section:D3ECFE43-D079-4427-8C48-157BD4C55F4C_des|text=|trigger=button}{sub-section}{sub-section:D3ECFE43-D079-4427-8C48-157BD4C55F4C_des|trigger=none|class=sIndent}The join type that is performed between the primary table and the foreign table. Can be "inner join" or "left outer join".{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:D3ECFE43-D079-4427-8C48-157BD4C55F4C_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:D3ECFE43-D079-4427-8C48-157BD4C55F4C_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:D3ECFE43-D079-4427-8C48-157BD4C55F4C_ret|text=|trigger=button}{sub-section}{sub-section:D3ECFE43-D079-4427-8C48-157BD4C55F4C_ret|trigger=none|class=sIndent}[Number]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:D3ECFE43-D079-4427-8C48-157BD4C55F4C_see|text=|trigger=button}{sub-section}{sub-section:D3ECFE43-D079-4427-8C48-157BD4C55F4C_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:D3ECFE43-D079-4427-8C48-157BD4C55F4C_see|text=|trigger=button}{sub-section}{sub-section:D3ECFE43-D079-4427-8C48-157BD4C55F4C_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=sam}{td}*Sample*\\{sub-section:D3ECFE43-D079-4427-8C48-157BD4C55F4C_sam|text=|trigger=button}{sub-section}{sub-section:D3ECFE43-D079-4427-8C48-157BD4C55F4C_sam|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=D5EB26CB-1398-43FE-A662-EC2A32C07802}{tr:id=name}{td}h6.name{td}{tr}{tr:id=des}{td}{sub-section:D5EB26CB-1398-43FE-A662-EC2A32C07802_des|text=|trigger=button}{sub-section}{sub-section:D5EB26CB-1398-43FE-A662-EC2A32C07802_des|trigger=none|class=sIndent}The name of the relation.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:D5EB26CB-1398-43FE-A662-EC2A32C07802_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:D5EB26CB-1398-43FE-A662-EC2A32C07802_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:D5EB26CB-1398-43FE-A662-EC2A32C07802_ret|text=|trigger=button}{sub-section}{sub-section:D5EB26CB-1398-43FE-A662-EC2A32C07802_ret|trigger=none|class=sIndent}[String]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:D5EB26CB-1398-43FE-A662-EC2A32C07802_see|text=|trigger=button}{sub-section}{sub-section:D5EB26CB-1398-43FE-A662-EC2A32C07802_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:D5EB26CB-1398-43FE-A662-EC2A32C07802_see|text=|trigger=button}{sub-section}{sub-section:D5EB26CB-1398-43FE-A662-EC2A32C07802_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=sam}{td}*Sample*\\{sub-section:D5EB26CB-1398-43FE-A662-EC2A32C07802_sam|text=|trigger=button}{sub-section}{sub-section:D5EB26CB-1398-43FE-A662-EC2A32C07802_sam|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=E77A4941-F664-4DAA-87B8-ABB24150CD11}{tr:id=name}{td}h6.primaryTable{td}{tr}{tr:id=des}{td}{sub-section:E77A4941-F664-4DAA-87B8-ABB24150CD11_des|text=|trigger=button}{sub-section}{sub-section:E77A4941-F664-4DAA-87B8-ABB24150CD11_des|trigger=none|class=sIndent}Qualified name of the primary data source. Contains both the name of the primary server and the name of the primary table.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:E77A4941-F664-4DAA-87B8-ABB24150CD11_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:E77A4941-F664-4DAA-87B8-ABB24150CD11_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:E77A4941-F664-4DAA-87B8-ABB24150CD11_ret|text=|trigger=button}{sub-section}{sub-section:E77A4941-F664-4DAA-87B8-ABB24150CD11_ret|trigger=none|class=sIndent}[String]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:E77A4941-F664-4DAA-87B8-ABB24150CD11_see|text=|trigger=button}{sub-section}{sub-section:E77A4941-F664-4DAA-87B8-ABB24150CD11_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:E77A4941-F664-4DAA-87B8-ABB24150CD11_see|text=|trigger=button}{sub-section}{sub-section:E77A4941-F664-4DAA-87B8-ABB24150CD11_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=sam}{td}*Sample*\\{sub-section:E77A4941-F664-4DAA-87B8-ABB24150CD11_sam|text=|trigger=button}{sub-section}{sub-section:E77A4941-F664-4DAA-87B8-ABB24150CD11_sam|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{table}
Wiki Markup
Div
styledisplay:none

DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY (EXCEPT INSIDE THE DIV BELOW WITH ID=DESCRIPTION), UNLESS YOU KNOW WHAT YOU'RE DOING.
THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO AUTO UPDATE THE CONTENT THROUGH THE DOC GENERATOR.

Div
iddescription

Relations

By default, relations join together two datasources, for example a CUSTOMERS (source) and a ORDERS (destination) table. Through RelationItems the nature of the link between the datasources is defined, for example to link the CUSTOMERS and ORDERS table based on the customer_id column.

At runtime a relation is an object of type JSFoundSet. Relations are used in Solutions to display related data, for example using a Field , a TabPanel or a Portal or to work with related data in business logic.

Special Relations

Next to the default relations that link two datasources together, there are several other types of relations, based on how the relation is setup.

Global Relations

Relations that contain only RelationItems based on global variables on the source side, thus no dependency on the source table are considered global relations.

Global relations can be used to get a limited FoundSet, for example all active customers, by adding a relation item that specifies that the "active" flag in the CUSTOMERS table has to be equal to a certain global variable. For example, if the CUSTOMERS table (used as destination datasource) contains a column called "is_active" of type INTEGER and a default value of 1 (indicating it is an active record), the following would create a global relation that returns a FoundSet with all active customers:

Code Block
titleSetup a global variable
var ACTIVE = 1;

Image Added

A global variable can be defined as an enumeration of constants, using the @enum annotation. See Annotating JavaScript Using JSDoc. The constants of the enumeration can be used in relations just as the common global variables are used.

Code Block
titleSetup a global enumeration
/**
 * @enum
 */
var TEAM_COLORS = {
    RED : 1,
    GREEN : 2,
    BLUE : 3
}

Image Added

Container Relations

If the source and destination datasources are equal and the relation does not contain any RelationItems, it becomes a Container relation. A Container relation returns it originating FoundSet. A Container relation can be used to set the FoundSet of the parent form into the Form displayed in a TabPanel.

Selfjoins

Relations can use the same datasource as source and destination datasource. Depending on the setup of the the RelationItems the relation can point back to the originating record or one or more different records.

Relation Options

Relations have several settings that influence the behavior of the Relation under different circumstances.

Join Types

Join types determine the behavior of sorting when there are no related records and the sort is performed on related fields.

Inner join : When sorting records on related dataproviders over a relation that uses the "inner join" type, if a parent record does not have any related records, the parent record is excluded from the foundset
Left outer join : When sorting records on related dataproviders over a relation that uses the "left outer join" type, if a parent record does not have any related records, the parent record remains in the foundset

Tip
titleUse Left outer join

In most scenario's the "Left outer join" type is the join type to use for relations

Record Creation

Allow creation of related records : This property indicates if the relation can be used to create new related records

  • true: the execution of the newRecord() method on the relation (for example "customers_to_orders.newRecord()") will create a new record.
  • false: the execution of the newRecord() method on the relation will throw a ServoyException.NO_RELATED_CREATE_ACCESS exception.

Record Deletion

Allow parent delete when having related records : This property indicates if the parent record can be deleted if it has related records over this relation

  • true: When an attempt is made to delete the parent record, this relation WILL NOT be checked for the existence of records over this relation and thus it will not block the delete of the parent record
  • false: When an attempt is made to delete the parent record, a check WILL be made for the existence of records over this relation. When related records exist over this relation, the delete of the parent record will be blocked and a ServoyException.NO_PARENT_DELETE_WITH_RELATED_RECORDS exception will be thrown.
Note
title*Allow parent delete when having related records* overrules *Delete related records*

The option Allow parent delete when having related records overrules the option Delete related records . This means that if the first option is set to false, the latter option is ignored. Setting the first option to false and the latter option to true will still block the delete.

Note
titleAll relations for the datasource checked on delete

When an attempt is made to delete a record, each relation that uses the datasource of the record (that is to be deleted) as the source datasource is checked to see if it allows the delete to proceed. If one relation is found that blocks the delete, the entire delete will fail.

Note
titlePerformance

If the option Allow parent delete when having related records is set to false on a relation, when a record is deleted from the datasource that is used as the source datasource for the relation, a check will be made to see if there are related records. If many relations exist with the option set to false, this can impact the performance of deletes.

Delete related records : This property indicates if child records should be automatically deleted when the parent record is deleted

  • true: when the parent record is deleted and there are records over this relation, those related records will also get deleted.
  • false: related records will remain untouched.
Note
titleCascading deletes

Deletes cascade down when encountering relations on the related records that are to be deleted that also have the Delete related records property set to true. This means that when a record from the CUSTOMERS datasource is deleted and the relation customer_to_orders has the Delete related records set to true, the order records will also be deleted. If there is a relation order_to_orderitems that also has the Delete related records property set to true, the orderitem records will also get deleted.

Note
titleDeleting of related records can block the overall delete

When a relation has the Delete related records property set to true, an attempt is made to also delete all individual related records. On each individual related record the checks mentioned previous will also be performed. If any of the related records blocks the delete, the entire delete is blocked.

Example 1: A simple scenario
This example defines three relations in the typical customer > orders > orderitems setup:
Relation 1: customer_to_orders, allowParentDeleteWhenHavingRelatedRecords=true, deleteRelatedRecords=true
Relation 2: order_to_orderitems, allowParentDeleteWhenHavingRelatedRecords=true, deleteRelatedRecords=true
Relation 3: orderitem_to_product, allowParentDeleteWhenHavingRelatedRecords=true, deleteRelatedRecords=true

If an attempt is made to delete a customer record which has order and the orders have orderitems, when the relations are setup as described above the customer record will be deleted, all the orders related to the customer are deleted and all orderitems related to the orders of the customer will be deleted.

As Relation 3 has the deleteRelatedRecords property set to false, no attempt will be made to delete the product record related to the orderitems that are to be deleted.

Example 2: Implementing business logic enforcement in the data layer
This example defines four relations starting with the in the typical customer > orders > orderitems setup, followed by the following business logic enforced by the datamodel: If an order resulted in an Invoice, the id of the invoice is stored on the order record in the invoice_id column. If an order has a related invoice then it cannot be deleted
Relation 1: customer_to_orders, allowParentDeleteWhenHavingRelatedRecords=true, deleteRelatedRecords=true
Relation 2: order_to_orderitems, allowParentDeleteWhenHavingRelatedRecords=true, deleteRelatedRecords=true
Relation 3: orderitem_to_product, allowParentDeleteWhenHavingRelatedRecords=true, deleteRelatedRecords=true
Relation 4: order_to_invoice, allowParentDeleteWhenHavingRelatedRecords=false

This setup is mostly the same as example 1, except for the additional fourth relation. This relation from the orders table to the invoices defines that the order record cannot be deleted if it has a related invoice record.

In this setup, when an attempt is made to delete a customer record the delete is blocked if the customer has a related order that has a related invoice record.



HTML Table
id
classservoy sSummary
Colgroup Tag
Col
width80px
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Property Summary
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
allowCreationRelatedRecords
Flag that tells if related records can be created through this relation.
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
allowParentDeleteWhenHavingRelatedRecords
Flag that tells if the parent record can be deleted while it has related records.
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
deleteRelatedRecords
Flag that tells if related records should be deleted or not when a parent record is deleted.
Table Row (tr)
Table Cell (td)
String
Table Cell (td)
deprecated
Gets the deprecate info for this element
Table Row (tr)
Table Cell (td)
Number
Table Cell (td)
encapsulation
The encapsulation mode of this persist.
Table Row (tr)
Table Cell (td)
String
Table Cell (td)
foreignDataSource
Qualified name of the foreign data source.
Table Row (tr)
Table Cell (td)
String
Table Cell (td)
initialSort
A String which specified a set of sort options for the initial sorting of data
retrieved through this relation.
Table Row (tr)
Table Cell (td)
Number
Table Cell (td)
joinType
The join type that is performed between the primary table and the foreign table.
Table Row (tr)
Table Cell (td)
String
Table Cell (td)
name
The name of the relation.
Table Row (tr)
Table Cell (td)
String
Table Cell (td)
primaryDataSource
Qualified name of the primary data source.



HTML Table
idproperty
classservoy sDetail
Colgroup Tag
Col
colspan2
width100%
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Property Details
Table Body (tbody)
idallowCreationRelatedRecords
Table Row (tr)
idname
Table Cell (td)

allowCreationRelatedRecords

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent

Flag that tells if related records can be created through this relation.

The default value of this flag is "false".

Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idallowParentDeleteWhenHavingRelatedRecords
Table Row (tr)
idname
Table Cell (td)

allowParentDeleteWhenHavingRelatedRecords

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent

Flag that tells if the parent record can be deleted while it has related records.

The default value of this flag is "true".

Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
iddeleteRelatedRecords
Table Row (tr)
idname
Table Cell (td)

deleteRelatedRecords

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent

Flag that tells if related records should be deleted or not when a parent record is deleted.

The default value of this flag is "false".

Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
iddeprecated
Table Row (tr)
idname
Table Cell (td)

deprecated

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Gets the deprecate info for this element
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
String - the deprecate info for this element or null if it is not deprecated
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idencapsulation
Table Row (tr)
idname
Table Cell (td)

encapsulation

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent

The encapsulation mode of this persist. The following can be used/checked:

- Public (not a separate option - if none of the below options are selected)
- Hide in scripting; Module Scope - not available in scripting from any other context except the form itself. Available in designer for the same module.
- Module Scope - available in both scripting and designer but only in the same module.
- Hide Dataproviders (checked by default)
- Hide Foundset (checked by default)
- Hide Controller (checked by default)
- Hide Elements (checked by default)

Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Number - the encapsulation mode/level of the persist.
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idforeignDataSource
Table Row (tr)
idname
Table Cell (td)

foreignDataSource

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Qualified name of the foreign data source. Contains both the name of the foreign
server and the name of the foreign table.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
String
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idinitialSort
Table Row (tr)
idname
Table Cell (td)

initialSort

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent

A String which specified a set of sort options for the initial sorting of data
retrieved through this relation.

Has the form "column_name asc, another_column_name desc, ...".

Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
String
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idjoinType
Table Row (tr)
idname
Table Cell (td)

joinType

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
The join type that is performed between the primary table and the foreign table.
Can be "inner join" or "left outer join".
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Number
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idname
Table Row (tr)
idname
Table Cell (td)

name

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
The name of the relation.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
String
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idprimaryDataSource
Table Row (tr)
idname
Table Cell (td)

primaryDataSource

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Qualified name of the primary data source. Contains both the name of the primary server
and the name of the primary table.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
String
Table Row (tr)
classlastDetailRow
Table Cell (td)