SystemConstant.SelectById(ID, Query)
SystemConstant.SelectById(ID, Query) allows the user to select a system constant by the constant's ID (co_id).
Applies To
Description
SystemConstant.SelectById(ID, Query) allows the user to select a system constant by the constant's ID (co_id).
Note: Unless you are sure the ID's will not change between systems, we recommend using the SystemConstant.SelectByName(Name, Query) method instead, especially, since the co-name field must be unique in DEACOM.
Properties and Methods
Properties
Methods
Available
The .SelectById(ID, 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
Boolean
Syntax
SystemConstant.SelectById(ID, Query);
Parameters
Parameter |
Required |
Description |
---|---|---|
ID |
Yes |
An integer representing the ID 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 lnConstantID = 3; //-- the co_id of the system constant to return the value
let lnValue = SystemConstant.SelectById(lnConstantID, Query).co_value;
//--This script line returns the notes of a system constant
let lnConstantID = 5; //-- the co_id of the system constant to return the value
let lcNote = SystemConstant.SelectById(lnConstantID, 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 ID
function SetSystemConstantValueById(pnConstantID, pnValue)
{
let loConstant = SystemConstant.SelectById(pnConstantID, 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 = 'js_' + pnConstantID; //--can't set the ID, that is determined by DEACOM, and the name is required
loConstant.co_active = false;
}
loConstant.co_value = pnValue;
loConstant.Save();
}
//--Set the Notes of a given system constant ID
function SetSystemConstantNotesById(pnConstantID, pcNote)
{
let loConstant = SystemConstant.SelectById(pnConstantID, 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 = 'js_' + pnConstantID; //--can't set the ID, that is determined by DEACOM, and the name is required
loConstant.co_active = false;
}
loConstant.co_notes = pcNote;
loConstant.Save();
}