Wednesday, November 18, 2015
Monday, November 16, 2015
Find and exist methods
Find() :
Each table with a key should have a static find method. The method is used to find a record that fulfills the specified key.
Each table with a key should have a static find method. The method is used to find a record that fulfills the specified key.
The find method must:
- Be static because it is used to find a record among all the objects of the table class.
- Return an object of the type of the table (or null if not found).
- Be named find.
- Have a parameter of the same type as the key of the table or a list of parameters if the key consists of more than one field. If there is a list of parameters, they must be in the same order that the key fields are listed in the index that supports the key of the table.
- Have a Boolean parameter with a default value of false. If true, the record should be selected for update.
- Have an optional parameter to enable the default Concurrency Model behavior specified on the table to overruled. The default value for the parameter should be ConcurrencyModel::Auto.
- Make the most effective select operation for the single record from the table and return it. Use an index that matches the required field, and use the firstOnly keyword (see the following example).
- Run on both the client and the server. This is the default behavior. You can also make it explicit by putting "client server" in the declaration, but do not specify a single tier in the declaration (either the client or the server).
- Declare find methods as Public. If you do not, a best practices warning appears if the method is not used in the application. (The warning suggests that you declare the method as private because this is the most restrictive level of access.)
Example :
static CustTable find(CustAccount _custAccount, boolean _forUpdate = false)
{
CustTable custTable;
if (_custAccount)
{
if (_forUpdate)
{
custTable.selectForUpdate(_forUpdate);
}
select firstonly custTable
index hint AccountIdx
where custTable.AccountNum == _custAccount;
}
return custTable;
}
Exist() :
Each table with a key should have a static exist method. Use it to check if a record that fulfills the specified key actually exists.
The exist method must:
- Be static because it is used to check if any table object (record) exists among all the objects of the table class.
- Return a boolean value.
- Take an argument of the type of the key of the table or a list of arguments if the key consists of more than one field. If there is a list of arguments, they must be in the same order as the fields in the index that are used for the table's key.
- Check for the most effective, existing index in the record against the supplied key, and then return true if it is in the table. If not,false.
- Run on both the client and server. This is the default behavior. You can also make it explicit by putting "client server" in the declaration, but do not specify a single tier in the declaration (either the client or the server).
The method must be used whenever one record should be checked that is exists based on its key.
Example :
public static boolean exist(VendAccount _vendAccount )
{
boolean found;
;
found = (select firstonly RecId from vendTable
where
vendTable.AccountNum == _vendAccount).RecId != 0;
return found;
}
Subscribe to:
Posts (Atom)
update_recordset with joins
update_recordset with joins update_recordSet storeTransfer setting TransactionId = transfertable.TransferId join transfert...
-
void clicked() { EcoResProductMaster ecoResProductMaster; EcoResProductIdentifier ecoResProductIdent...
-
based on selected record from parent code lookup modify item id in purchase order. create a new custom lookup form as shown below. override ...
-
W rite below code in your UIBuilder Class public boolean validatePostingProfile(FormStringControl _control) { boolean ret = tru...