Tip>Designer

Auto-naming sub-Dialog Answer-sets in an embedded collection

 

Article #:

0034

Contributor:

Jeanine Howard

GF version:

4.0

Applies to:

Embedded collections and scripting in Dialogs

Last updated:

February 20, 2002

Description

Add script to a sub-Dialog form that will automatically name a sub-Dialog Answer-set in an embedded collection. When the sub-Dialog Answer-set is created and populated with data, the form event uses the data entered into a specific field to name the sub-Dialog Answer-set.

Explanation

You can add script to a Dialog form's "OnEnter" and "OnExit" events. When you reference this Dialog as a sub-Dialog in an embedded sub-Dialog collection, and add sub-Dialog Answer-sets to the collection, these events are executed each time you "enter" and "exit" a sub-Dialog Answer-set. The script in the events will name the sub-Dialog Answer-set according to the data typed in a specific field in the sub-Dialog Answer-set.

 

You can choose any field in your sub-Dialog to name your sub-Dialog Answer-set. You can even build up the name based on more than one field, e.g. Title&FirstName&Surname.

 

Click here to view an example

Let us assume you have a Dialog that contains an embedded sub-Dialog collection called "ClientsCollection". This collection connects to a sub-Dialog called "Clients". In the Clients sub-Dialog there is a field called "NameAnswerSet". The contents of this field will be used to name the sub-Dialog Answer-set.

To automatically name a sub-Dialog Answer-set using script:

  1. Add script to the Clients sub-Dialog:

%[ThisDialog.NameAnswerSet = ThisDialog._Name]

%[ThisDialog._Name = ThisDialog.NameAnswerSet]

  1. Create a sub-Dialog Answer-set in the collection and go to the new sub-Dialog Answer-set. The "OnEnter" event is executed. The NameAnswerSet field is updated with the name GhostFill has automatically generated for the sub-Dialog Answer-set, e.g. New_ClientsCollection_1.

  2. Fill in the sub-Dialog Answer-set and update the NameAnswerSet field with a new name, e.g. P Jones. When you click the Back button to return to the main Dialog, the "OnExit" event is executed and the contents of the NameAnswerSet field become the new name of the sub-Dialog Answer-set in the embedded collection.

 

NOTE

For more information on creating collections, adding Dialog Answer-sets to collections and scripting in Dialogs, see the GhostFill Developer Guide.