The Code Script control that appears on a form is linked to the embedded ScriptID in an entity (note that this does not apply to the Database Objects service).
When you enter a script in the control and save a record, Aptify automatically creates a Scripts record and populates the following fields:
- Script Language: The Code Script control on an entity's form is hard coded with a specific ScriptLanguageID. This selection flows down to the Scripts record.
- Script Type: The Code Script control on an entity's form is hard coded with a specific ScriptTypeID. This selection flows down to the Scripts record.
- Script Name: The system automatically generates a name for a script based on information from the record that embeds that script using the following format:
- Message Templates: [Entity Name].[Field Name]([Record's Name].SystemID=[Record's DefaultMessageSystemID],SourceID=[Record's DefaultMessageSourceID])
- E.g.: Message Templates.HTMLScriptID(Address Verification.SystemID=5,SourceID=2)
- Message Parts: [Entity Name].[Field Name]([Record's Name].CategoryID=[Record's CategoryID])
- E.g.: Message Parts.HTMLScriptID(Two Line Address Block.CategoryID=7)
- All Other Script Types: [Entity Name].[Field Name]([Record's Name])
- E.g.: Process Flow Steps.RuleTextScriptID(Show "Pending")
- For top-level Entities, the Record's Name is the value stored in the Name field.
- For Sub-Types, the Record's Name also includes the value of the Name fields throughout the parent hierarchy, separated by the period (.). For example, a field validation script for the Calculation Type field in the Shipment Types entity has this script name: EntityFields.ValidationScriptID(Shipment Types.CalculationType)
- Script Text: The user-defined script is stored in this field.
The Code Script control includes a toolbar with two icons. When writing a script, you can click one of these icons to see the references and intrinsic objects that are available for use in the script and to see relevant examples (if available). The information that is displayed when you click one of these icons flows down from the appropriate Script Types record.
Code Script Control Icons
The icons are as follows, from left to right:
- Available Objects: Click this icon to display the intrinsic objects available for this type of script (see Figure 11.90). The objects flow down from the applicable Script Type's Available Objects tab. You can add an object to your script by placing the cursor in the desired location before clicking the Available Objects icon. Then, double-click an object or select an object and click Copy to add it to the specified location within the script. Note that double-clicking an object or clicking Copy closes the Available Objects dialog. Available Objects Dialog
- All References: Click this icon to display the list of references available for a script of this type. The references are separated into two categories: GAC Reference and Repository Reference (as shown in Figure 11.91). GAC References are objects in the Windows Global Assembly Cache. Repository References are objects in the Aptify Object Repository. The available references flow down from the applicable Script Type's Repository References and GAC References tabs. All References Dialog
- Example Script: Click this icon to display any sample scripts provided for this script type. You can copy all or a portion of a sample script by placing the cursor in the desired location before clicking the Example Script icon. Then, highlight the text you want to copy to your script and click Copy. The Examples dialog closes and the text is added to the specified location within the script.
- The examples flow from a Script Type's Languages tab. For each Script Type's Languages sub-type record, you can specify a supported scripting language and provide sample code that will appear when a user clicks the Example Script icon.
- The Example Script icon will not appear if there is no sample code provided in a Script Type's Languages sub-type record.