project BLF > class BStoredSearch > method apiGetLookupInformation
Description
Returns a list of available stored searches and all data of default (last used) stored search
Parameters
iiCurrentRoleID | input | integer | ID of current role |
icLookupReference | input | character | Lookup reference |
ilskipStoredSearch | input | logical | ignore last-used stored search |
oiRowsToRetrieve | output | integer | RowsToRetrieve |
ocSortColumn | output | character | SortColumn |
olFilterPanelsMinimized | output | logical | FilterPanelsMinimized |
olFreezeFirstColumn | output | logical | FreezeFirstColumn |
olUseGridLayout | output | logical | |
olCompanyDependent | output | logical | |
olAutoApplyFilter | output | logical | |
oiAccessLevel | output | integer | |
ocLayoutXML | output | character | |
olStoredSearchLoaded | output | logical | loaded |
ocStoredSearchName | output | character | |
tFilterFields | output | temp-table | Filter fields |
tResultFields | output | temp-table | Result fields |
tStoredSearchList | output | temp-table | list |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program3/bstoredsearch.p)
empty temp-table tFilterFields.
empty temp-table tResultFields.
empty temp-table tStoredSearchList.
if icLookupReference = ""
or icLookupReference = ?
then return.
if oiReturnStatus = 0
then oiReturnStatus = -98.
<Q-8 run GetStoredSearch (Start) in BStoredSearch >
<Q-5 run GetStoredSearch (all) (Read) (NoCache)
(input icLookupReference, (Reference)
input viCompanyId, (CompanyId)
input iiCurrentRoleID, (RoleID)
input viUsrId, (UserID)
input '', (Name)
output dataset tqGetStoredSearch) in BStoredSearch >
if not (icLookupReference begins "/" or
can-find (first tqGetStoredSearch where tqGetStoredSearch.tcStoredSearchName = {&STOREDSEARCH-FACTORY-DEFAULT}))
then do:
<Q-7 run GetStoredSearch (all) (Append) (NoCache)
(input '/':U + entry (num-entries(icLookupReference,'/':U),icLookupReference,'/':U), (Reference)
input viCompanyId, (CompanyId)
input iiCurrentRoleID, (RoleID)
input viUsrId, (UserID)
input {&STOREDSEARCH-FACTORY-DEFAULT}, (Name)
output dataset tqGetStoredSearch) in BStoredSearch >
end.
/* create a list of all available stored search */
for each tqGetStoredSearch where
tqGetStoredSearch.tcStoredSearchName <> {&STOREDSEARCH-LAST-USED} + "_":U + vcUserLogin
on error undo, return:
create tStoredSearchList.
assign tStoredSearchList.tcAccessLevelLabel = (if tqGetStoredSearch.tiUsr_ID = 0
then if tqGetStoredSearch.tiRole_ID = 0
then {&CONTROLPROPERTYLAYERTYPE-SYSTEM-TR}
else {&CONTROLPROPERTYLAYERTYPE-ROLE-TR}
else {&CONTROLPROPERTYLAYERTYPE-USER-TR})
tStoredSearchList.tiAccessLevel = (if tqGetStoredSearch.tiUsr_ID = 0
then if tqGetStoredSearch.tiRole_ID = 0
then {&CONTROLPROPERTYLAYERTYPE-SYSTEM}
else {&CONTROLPROPERTYLAYERTYPE-ROLE}
else {&CONTROLPROPERTYLAYERTYPE-USER})
tStoredSearchList.tlCompanyDependent = (tqGetStoredSearch.tiCompany_ID <> 0)
tStoredSearchList.tcStoredSearchName = tqGetStoredSearch.tcStoredSearchName
tStoredSearchList.tiStoredSearchId = tqGetStoredSearch.tiStoredSearch_ID
tStoredSearchList.tlIsFactoryDefault = false
tStoredSearchList.tlIsCustomerDefault = false.
if tStoredSearchList.tcStoredSearchName = {&STOREDSEARCH-FACTORY-DEFAULT}
then assign tStoredSearchList.tcStoredSearchName = {&STOREDSEARCH-FACTORY-DEFAULT-TR}
tStoredSearchList.tlIsFactoryDefault = true.
if tStoredSearchList.tcStoredSearchName = {&STOREDSEARCH-CUSTOMER-DEFAULT}
then assign tStoredSearchList.tcStoredSearchName = {&STOREDSEARCH-CUSTOMER-DEFAULT-TR}
tStoredSearchList.tlIsCustomerDefault = true.
end.
/* load all data of default stored search */
if ilskipStoredSearch
then release tqGetStoredSearch.
else find first tqGetStoredSearch where
tqGetStoredSearch.tcStoredSearchName = {&STOREDSEARCH-LAST-USED} + "_":U + vcUserLogin no-error.
if not available tqGetStoredSearch
then find first tqGetStoredSearch where
tqGetStoredSearch.tcStoredSearchName = {&STOREDSEARCH-CUSTOMER-DEFAULT} no-error.
if not available tqGetStoredSearch
then find first tqGetStoredSearch where
tqGetStoredSearch.tcStoredSearchName = {&STOREDSEARCH-FACTORY-DEFAULT} and
tqGetStoredSearch.tcStoredSearchLookupRef = icLookupReference no-error.
if not available tqGetStoredSearch
then find first tqGetStoredSearch where
tqGetStoredSearch.tcStoredSearchName = {&STOREDSEARCH-FACTORY-DEFAULT} no-error.
if not available tqGetStoredSearch
then find first tqGetStoredSearch no-error.
if available tqGetStoredSearch
then viLoadID = tqGetStoredSearch.tiStoredSearch_ID.
<Q-9 run GetStoredSearch (Stop) in BStoredSearch >
if viLoadID <> 0
then do:
<M-2 run DataLoad
(input '' (icRowids),
input string(viloadID) (icPkeys),
input '' (icObjectIds),
input '' (icFreeform),
input no (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BStoredSearch>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
find first tStoredSearch no-error.
if available tStoredSearch
then do:
assign oiRowsToRetrieve = tStoredSearch.StoredSearchRowsToRetrieve
ocSortColumn = tStoredSearch.StoredSearchSortColumn
olFilterPanelsMinimized = tStoredSearch.StoredSearchFilterMinimize
olFreezeFirstColumn = tStoredSearch.StoredSearchFreezeFirstCol
olUseGridLayout = tStoredSearch.StoredSearchUseGridLayout
ocLayoutXML = tStoredSearch.StoredSearchLayoutXML
olCompanyDependent = (tStoredSearch.Company_ID = viCompanyId)
olAutoApplyFilter = tStoredSearch.StoredSearchAutoApply
oiAccessLevel = (if tStoredSearch.Usr_ID = 0
then if tStoredSearch.Role_ID = 0
then {&CONTROLPROPERTYLAYERTYPE-SYSTEM}
else {&CONTROLPROPERTYLAYERTYPE-ROLE}
else {&CONTROLPROPERTYLAYERTYPE-USER})
vcRowid = tStoredSearch.tc_Rowid
olStoredSearchLoaded = yes
ocStoredSearchName = if tStoredSearch.StoredSearchName = {&STOREDSEARCH-FACTORY-DEFAULT}
then {&STOREDSEARCH-FACTORY-DEFAULT-TR}
else
if tStoredSearch.StoredSearchName = {&STOREDSEARCH-CUSTOMER-DEFAULT}
then {&STOREDSEARCH-CUSTOMER-DEFAULT-TR}
else
if tStoredSearch.StoredSearchName begins {&STOREDSEARCH-LAST-USED}
then "":U
else tStoredSearch.StoredSearchName.
end.
end.
<M-3 run GetFields (input icLookupReference (icLookupReference),
input vcRowid (icSSRowid),
output viFcReturnSuper (oiReturnStatus)) in BStoredSearch>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
if not can-find (first tResultFields where tResultFields.tlIsVisible)
then for each tResultFields:
tResultFields.tlIsVisible = yes.
end.
if oiReturnStatus = -98
then oiReturnStatus = 0.
Sample code: how to call this method through RPCRequestService (QXtend Inbound)
define temp-table ttContext no-undo
field propertyQualifier as character
field propertyName as character
field propertyValue as character
index entityContext is primary unique
propertyQualifier
propertyName
index propertyQualifier
propertyQualifier.
define dataset dsContext for ttContext.
define variable vhContextDS as handle no-undo.
define variable vhExceptionDS as handle no-undo.
define variable vhServer as handle no-undo.
define variable vhInputDS as handle no-undo.
define variable vhInputOutputDS as handle no-undo.
define variable vhOutputDS as handle no-undo.
define variable vhParameter as handle no-undo.
/* Create context */
create ttContext.
assign ttContext.propertyName = "programName"
ttContext.propertyValue = "BStoredSearch".
create ttContext.
assign ttContext.propertyName = "methodName"
ttContext.propertyValue = "apiGetLookupInformation".
create ttContext.
assign ttContext.propertyName = "applicationId"
ttContext.propertyValue = "fin".
create ttContext.
assign ttContext.propertyName = "entity"
ttContext.propertyValue = "1000".
create ttContext.
assign ttContext.propertyName = "userName"
ttContext.propertyValue = "mfg".
create ttContext.
assign ttContext.propertyName = "password"
ttContext.propertyValue = "".
/* Create input dataset */
create dataset vhInputDS.
vhInputDS:read-xmlschema("file", "xml/bstoredsearch.apigetlookupinformation.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::iiCurrentRoleID = <parameter value>
vhParameter::icLookupReference = <parameter value>
vhParameter::ilskipStoredSearch = <parameter value>.
/* Connect the AppServer */
create server vhServer.
vhServer:connect("-URL <appserver-url>").
if not vhServer:connected()
then do:
message "Could not connect AppServer" view-as alert-box error title "Error".
return.
end.
/* Run */
assign vhContextDS = dataset dsContext:handle.
run program/rpcrequestservice.p on vhServer
(input-output dataset-handle vhContextDS by-reference,
output dataset-handle vhExceptionDS,
input dataset-handle vhInputDS by-reference,
input-output dataset-handle vhInputOutputDS by-reference,
output dataset-handle vhOutputDS).
/* Handle output however you want, in this example, we dump it to xml */
if valid-handle(vhExceptionDS)
then vhExceptionDS:write-xml("file", "Exceptions.xml", true).
if valid-handle(vhOutputDS)
then vhOutputDS:write-xml("file", "Output.xml", true).
/* Cleanup */
vhServer:disconnect().
assign vhServer = ?.
if valid-handle(vhInputDS)
then delete object vhInputDS.
if valid-handle(vhOutputDS)
then delete object vhOutputDS.
if valid-handle(vhExceptionDS)
then delete object vhExceptionDS.