SystemConstant.SelectByName(Name, Query)
SystemConstant.SelectByName(Name, Query) allows the user to select a system constant by the constant's name (co_name).
Applies To
Description
SystemConstant.SelectByName(Name, Query) allows the user to select a system constant by the constant's name (co_name). We have found this method to be easier than the SystemConstant.SelectById(ID, Query) method, because the:
- Name is required to be unique in DEACOM
- The name is already on the system constant grid by default
Properties and Methods
Properties
Methods
Available
The .SelectByName(Name, Query) method is available in:
- 15.03.090
- 15.04.059
- 15.05.034
- 16.00.039
- 16.01.011
- 16.02.004
- 16.03.001
- All newer builds
Type
SystemConstant
Syntax
SystemConstant.SelectByName(Name, Query);
Parameters
Parameter |
Required |
Description |
---|---|---|
Name |
Yes |
A string representing the name of a system constant entry in the DEACOM database |
Query |
Yes |
Must be the word Query with a capital Q. Tells DEACOM how to find the information provided in the first parameter. |
Example
//--This script line returns the value of a system constant
let lcName = 'js_New_Example'; //-- the co_name of the system constant to return the value
let lnValue = SystemConstant.SelectById(lcName, Query).co_value;
//--This script line returns the notes of a system constant
let lcName = 'js_Old_Example'; //-- the co_name of the system constant to return the Notes
let lcNote = SystemConstant.SelectById(lcName, Query).co_notes;
//--When setting the value of a system constant, we have found that creating a utility function is the best way to go
//--A utility function can be stored in an external file and called using Script.Include(Path)
//--Set the value of a given system constant Name
function SetSystemConstantValue(pcName, pnValue)
{
let loConstant = SystemConstant.SelectById(pcName, Query);
if(loConstant === null) //--if the constant does not exist, it will be returned as null, then create the new constant
{
loConstant = new SystemConstant;
loConstant.co_name = pcName;
loConstant.co_active = false;
}
loConstant.co_value = pnValue;
loConstant.Save();
}
//--Set the Notes of a given system constant ID
function SetSystemConstantNotes(pcName, pcNote)
{
let loConstant = SystemConstant.SelectById(pcName, Query);
if(loConstant === null) //--if the constant does not exist, it will be returned as null, then create the new constant
{
loConstant = new SystemConstant;
loConstant.co_name = pcName;
loConstant.co_active = false;
}
loConstant.co_notes = pcNote;
loConstant.Save();
}