Event.Form.Controls(FID)
Event.Form.Controls(FID) returns the form input element object identified by the Functional ID (FID). The Controls elements allow are the buttons and section form elements. The Event.Form.Controls(FID) allows the user to access the properties of the element like Enabled, and Visible.
Note: Getting any form element object is an expensive scripting process. It is highly recommended that you only get a form element object once and store it in a local pointer object variable. Then use the pointer variable to get and set the various properties. See the example below.
WARNING: When deploying a section FID to the Conrtols() method, this process has changed over the versions. At this time, it is not known specifically where this process changed. In earlier versions of Deacom 17.01 and earlier, if you had a user-defined caption for the section name ('My New Tab'), you were required to use Section_[caption ID]: 'Section_1850'. In 17.02 it is now the user-defined caption name without spaces: 'Section_MyNewTab'. Please note that any older iterations using the caption ID will not work in 17.02 or newer versions!
Applies To
Properties and Methods
Properties
Available
The .Controls(FID) method is available in:
- 15.03.016
- All newer builds
Note: The .Controls(FID) method and all sub-classes, properties, and methods are only available in Form Layout scripts.
Type
Control
Syntax
Event.Form.Controls(FID);
Parameters
|
Parameter |
Required |
Description |
|---|---|---|
|
FID |
Yes |
The Functional Identifier of the input element. To find this, prior to 17.02, right-click on the caption of the control you want to identify. The contextual menu will include a line for The Functional ID. |
Example
//--add this script to the click event of any save button
var lpSave = Event.Form.Controls('Button_Save');
if(Event.Form.YesNo('Do you want to save this record?'))
{
Event.Base();
}
Event.Form.MessageBox('Enabled: ' + lpSave.Enabled);
/* Expected Prompt response:
Do you want to save this record?
Yes No
*/
//-- If the user clicks yes, then DEACOM will save the record, otherwise nothing will happen.
/* Expected Prompt response:
If the user clicks Yes, then: Enabled: false
If the user clicks no, then: Enabled: true
*/
Helper Function
//--The section name used as the FID changes with the versions of Deacom and if the name is user-defined or system-defined.
//--This helper function takes the Section Name Caption (as seen in the tab) and converts it to the correct Functional ID.
function GetSectionName(pcSectionTitle)
{
let lnMaj = Convert.ToInteger(String.Left(Globals.Build, 2);
let llNew = true;
if(lnMaj < 17)
{
llNew = false;
}
else if(lnMaj = 17)
{
let lnMin = Convert.ToInteger(String.SubString(Globals.Build, 2, 2));
if(lnMin < 2)
{
llNew = false;
}
}
let lcSelect = `SELECT CONCAT('Section_', CASE c2_user WHEN 0 THEN Replace(RTRIM(c2_caption), ' ', '') WHEN 1 THEN Replace(RTRIM(c2_caption), ' ', '') ELSE 'Deacom' END ) AS SectionFID, c2_user`;
if(!llNew)
{
lcSelect = `SELECT CONCAT('Section_', CASE c2_user WHEN 0 THEN Replace(RTRIM(c2_caption), ' ', '') WHEN 1 THEN TRY_CONVERT(VARCHAR, c2_id) ELSE 'Deacom' END ) AS SectionFID, c2_user`;
}
Query.ClearParameters();
Query.AddParameter(pcSectionTitle);
let lcFID = Query.GetString(`
SELECT TOP 1 SectionFID
FROM (
SELECT 'Section_Deacom' AS SectionFID, -1 AS c2_user
UNION
${lcSelect}
FROM ${Query.SystemDatabase}.dbo.dxcaption2
WHERE c2_caption = {0}
) sub
ORDER BY sub.c2_user DESC
`);
return lcFID;
}