|
Tip>Designer |
|
|
Dynamically create a mapping off the Dialogs plug-in |
|
|
Article #: |
0039 |
|
Contributor: |
Daniel Todes |
|
GF version: |
4.0 |
|
Applies to: |
Mappings and Dialog Answer-sets |
|
Last updated: |
April 5, 2002 |
Description
Test for the existence of a mapping off the Dialogs plug-in. If it does not exist, create it dynamically. You can also test for the existence of a Dialog Answer-set in the mapping.
Explanation
You can use scripting in FillPoints to test for the existence of a specific mapping off the Dialogs plug-in. If the mapping does not exist, you can create it dynamically.
Click here to view a step-by-step example.
Set the variable values for the mapping name and the storage path:
Create the mapping name, for example, using a Profile variable:
%[DialogMappingName = Profiles.UserName & "Dialog Mapping"]
Set the path where the Answer-sets are to be saved:
%[DialogMappingPath = "c:\" & Profiles.UserName & "\MyAnswerSets"]
|
NOTE |
|
Test to see whether the mapping already exists in the Dialogs plug-in. If it does not, you can create it dynamically:
%[DeleteBlockIf(Explorer.Application("Default").Plugin(Dialogs).Mappings.Exists(DialogMappingName))]
%[~Explorer.CreateMapping("Default", Dialogs, DialogMappingName, DialogMappingPath)]
%[EndBlock()]
Refresh the mappings list (this ensures that the new mapping is available):
%[Explorer.Applications.Refresh]
If you ever need to remove the mapping, you can use the following FillPoint:
%[~Explorer.RemoveMapping("Default", Dialogs, MappingName)]
You can also test for the existence of a Dialog Answer-set in the mapping. If the Answer-set exists, open it for editing; if it does not, create it dynamically.
Click here to view a step-by-step example.
Store the name for the Dialog Answer-set in a variable:
%[AnswerSetName = "xyz"]
Test to see whether the Answer-set already exists. If it does, open it for editing:
%[KeepBlockIf(Dialogs.Exists(DialogMappingName, AnswerSetName))]
%[X=Dialogs.Select(DialogMappingName, AnswerSetName)]
%[Dialogs.Edit(X)]
%[EndBlock()]
If the Answer-set does not exist, create it from the "master" Dialog, save it to the new mapping name and then open it for editing:
%[DeleteBlockIf(Dialogs.Exists(DialogMappingName, AnswerSetName))]
%[X=Dialogs.New("\GF General Office Samples\Contacts", "xyz")]
%[X._Mapping=DialogMappingName]
%[Dialogs.Save(X, True)]
%[Dialogs.Edit(X)]
%[EndBlock()]