project BLF > class BStoredSearch > method ValidateComponent
Description
Write here all tests on database update (new / modify / delete) that cannot be coded with a validation mask.
The type of update can be found in tc_status (N/C/D).
If you find incorrect data, you must write an entry in tFcMessages (using SetMessage) and set the return status of this method to either +1 or -1.
Return status +1 = data will still be accepted.
Return status -1 = data will not be accepted.
This method is run from SetPublicTables, before transferring the received data into the class temp-tables.
Parameters
oiReturnStatus | output | integer | |
Internal usage
unused
program code (program/bstoredsearch.p)
/* BLF-3502 : replace with value with correct size */
for each t_sSSearchFilterField where
t_sSSearchFilterField.SSearchFilterFieldOperator = "isnotnull" and
(t_sSSearchFilterField.tc_Status = "C" or
t_sSSearchFilterField.tc_Status = "N") on error undo, throw:
t_sSSearchFilterField.SSearchFilterFieldOperator = "!null".
end.
<ANCESTOR-CODE>
/* You can only delete or modify your own stored searches. */
for each t_sStoredSearch where
t_sStoredSearch.tc_Status = "C":U or
t_sStoredSearch.tc_Status = "D":U on error undo, throw:
find t_oStoredSearch where
t_oStoredSearch.tc_Rowid = t_sStoredSearch.tc_Rowid
no-error.
if available t_oStoredSearch
and t_oStoredSearch.LastModifiedUser <> vcUserLogin
and not can-do ("mfg,FacDef":U,vcUserLogin)
and vlSkipValidationOfUser = false
then do:
if t_sStoredSearch.tc_Status = "D":U
then vcFcMaskList = #T-3'You are not allowed to delete this stored search.':100(435)T-3#.
else vcFcMaskList = #T-4'You are not allowed to modify this stored search.':100(6581)T-4#.
<M-1 run SetMessage (input vcFcMaskList (icMessage),
input '' (icArguments),
input 't_sStoredSearch.StoredSearchName':U (icFieldName),
input t_oStoredSearch.StoredSearchName (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_oStoredSearch.tc_Rowid (icRowid),
input 'BLF-216':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BStoredSearch>
assign oiReturnStatus = -1.
end.
end.
/* ================================================================= */
/* Only some users are allowed to delete factory defaults. */
/* ================================================================= */
if not can-do ("mfg,FacDef":U,vcUserLogin)
then for each t_sStoredSearch where
t_sStoredSearch.tc_Status = "D":U,
each t_oStoredSearch where
t_oStoredSearch.tc_Rowid = t_sStoredSearch.tc_Rowid and
t_oStoredSearch.StoredSearchName = {&STOREDSEARCH-FACTORY-DEFAULT} on error undo, throw:
<M-5 run SetMessage (input #T-5'You are not allowed to delete factory defaults.':100(6633)T-5# (icMessage),
input '' (icArguments),
input 't_sStoredSearch.StoredSearchName':U (icFieldName),
input t_oStoredSearch.StoredSearchName (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_oStoredSearch.tc_Rowid (icRowid),
input 'BLF-217':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BStoredSearch>
assign oiReturnStatus = -1.
end.