icBusComponentCode | input | character | Code of the BusinessComponent If filled then this method will only return Customisations, ReportVariants and the StoredSearches for that business-component. |
icBusComponentLabel | input | character | Label of the BusinessComponent If filled then this method will only return Customisations, ReportVariants and the StoredSearches for that business-component. |
icBusActivityCode | input | character | Code of the BusinessActivity If filled then this method will only return Customisations for that business-activity - but no ReportVariants or StoredSearches at all - |
icBusActivityLabel | input | character | Label of the BusinessActivity If filled then this method will only return Customisations for that business-activity - but no ReportVariants or StoredSearches at all - |
iiLayerType | input | integer | Limitation on which customization levels (= layer types) to look for : 0 / 1 = check all levels 2 = only check role + system level 3 = only check system level |
ilIncludeRepVarAndStoredSearches | input | logical | IncludeRepVarAndStoredSearches: Set to false in case you want this method to only return the pure customisations - that can all be deleted from this class. Set to true in case you want this method to also return the ReportVariants and the StoredSearches - Note that in this case the ReportVariants and the StoredSearches cannot be marked to be deleted. - Note that in this case the input parameters on BusActivity and icForm cannot be filled |
icForm | input | character | |
tCustomisedLevels | output | temp-table | |
oiReturnStatus | output | integer | Return status of the method. |
/* =============== */ /* Initialisations */ /* =============== */ empty temp-table tCustomisedLevels. empty temp-table tqBusActivityByLabeslCodesIDs. if icBusActivityCode = ? then icBusActivityCode = "". if icBusActivityLabel = ? then icBusActivityLabel = "". if icBusComponentCode = ? then icBusComponentCode = "". if icBusComponentLabel = ? then icBusComponentLabel = "". if iiLayerType = ? then assign iiLayerType = 0. if ilIncludeRepVarAndStoredSearches = ? then assign ilIncludeRepVarAndStoredSearches = false. if icForm = ? then icForm = "". /* =============================================================================================================== */ /* If one of the parameters about BusComp/BusAct is filled in, we get the BusComponents and BusActivities first */ /* If this is not the case then we create one dummy record in case no selection was made in the selection criteria */ /* =============================================================================================================== */ if icBusComponentCode <> "" or icBusComponentLabel <> "" or icBusActivityCode <> "" or icBusActivityLabel <> "" then do: <Q-66 run BusActivityByLabeslCodesIDs (all) (Read) (NoCache) (input ?, (BusComponentID) input icBusComponentCode, (BusComponentCode) input icBusComponentLabel, (BusComponentLabel) input ?, (BusActivityID) input icBusActivityCode, (BusActivityCode) input icBusActivityLabel, (BusActivityLabel) output dataset tqBusActivityByLabeslCodesIDs) in BBusinessComponent> end. /* if icBusComponentCode <> "" or */ else do: create tqBusActivityByLabeslCodesIDs. assign tqBusActivityByLabeslCodesIDs.tiBusActivity_ID = 0 tqBusActivityByLabeslCodesIDs.tiBusComponent_ID = 0. end. /* Not if icBusComponentCode <> "" or */ /* ========================================================================================== */ /* XXXXXXXXXXXXXXXXXX PART 1: PURE CUSTOMISATIONS XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ /* ========================================================================================== */ /* =================================================== */ /* Go through all BusComp/BusAct that were read before */ /* =================================================== */ for each tqBusActivityByLabeslCodesIDs on error undo, throw: /* =================================================== */ /* Query the control-properties for the BusComp/BusAct */ /* =================================================== */ empty temp-table tqLookupControlProperties. <Q-34 run LookupControlProperties (all) (Read) (NoCache) (input tqBusActivityByLabeslCodesIDs.tiBusActivity_ID, (BusActivityID) input iiLayerType, (LayerType) input icBusComponentCode, (BusComponentCode) input icBusComponentLabel, (BusComponentLabel) input icBusActivityCode, (BusActivityCode) input icBusActivityLabel, (BusActivityLabel) input icForm, (Form) output dataset tqLookupControlProperties) in BControlProperty> for each tqLookupControlProperties where tqLookupControlProperties.tcControlPropertyWindow >= icForm and tqLookupControlProperties.tcControlPropertyWindow <= (if icForm = "" then fill("z", 100) else icForm) and tqLookupControlProperties.tiControlPropertyLayerType >= iiLayerType and tqLookupControlProperties.tiControlPropertyLayerType <= (if iiLayerType = 0 then 9 else iiLayerType) on error undo, throw: /* ================= */ /* Fill the gridname */ /* ================= */ if tqLookupControlProperties.tcControlPropertyName = {&CONTROLPROPERTY-VIEWSDEFINITIONS} then vcGridDisplayName = entry (num-entries(tqLookupControlProperties.tcControlPropertyControl,":"),tqLookupControlProperties.tcControlPropertyControl,":"). else vcGridDisplayName = "". /* ======================= */ /* Create an output record */ /* ======================= */ if not (tqLookupControlProperties.tcControlPropertyName = {&CONTROLPROPERTY-VIEWSDEFINITIONS} and tqLookupControlProperties.tiControlPropertyLayerType = {&CONTROLPROPERTYLAYERTYPE-SYSTEM} and vcUserLogin <> "facdef") /* skip grid factory defaults */ then if not can-find (first tCustomisedLevels where tCustomisedLevels.tcBusComponentCode = tqLookupControlProperties.tcBusComponentCode and tCustomisedLevels.tcBusActivityCode = tqLookupControlProperties.tcBusActivityCode and tCustomisedLevels.tiLayerType = tqLookupControlProperties.tiControlPropertyLayerType and tCustomisedLevels.tiLayerValue = tqLookupControlProperties.tiControlPropertyLayerValue and tCustomisedLevels.tcForm = tqLookupControlProperties.tcControlPropertyWindow and tCustomisedLevels.tcGridDisplay = vcGridDisplayName) then do: create tCustomisedLevels. assign tCustomisedLevels.tiLayerType = tqLookupControlProperties.tiControlPropertyLayerType tCustomisedLevels.tiLayerValue = tqLookupControlProperties.tiControlPropertyLayerValue tCustomisedLevels.tcBusComponentCode = tqLookupControlProperties.tcBusComponentCode tCustomisedLevels.tcBusComponentLabel = tqLookupControlProperties.tcBusComponentLabel tCustomisedLevels.tcBusActivityCode = tqLookupControlProperties.tcBusActivityCode tCustomisedLevels.tcBusActivityLabel = tqLookupControlProperties.tcBusActivityLabel tCustomisedLevels.tiBusActivityID = tqLookupControlProperties.tiBusActivity_ID tCustomisedLevels.tcForm = tqLookupControlProperties.tcControlPropertyWindow tCustomisedLevels.tcGrid = (if tqLookupControlProperties.tcControlPropertyName = {&CONTROLPROPERTY-VIEWSDEFINITIONS} then tqLookupControlProperties.tcControlPropertyControl else "") tCustomisedLevels.tcGridDisplay = vcGridDisplayName. end. /* if not can-find */ end. /* for each tqLookupControlProperties where */ end. /* for each tqBusActivityByLabeslCodesIDs on error undo, throw: */ /* ========================================================================================= */ /* XXXXXXXXXXXXXXXXXX PART 2: REPORT-VARIANTS AND STORED-SEARCHES XXXXXXXXXXXXXXXXXXXXXXXXXX */ /* ========================================================================================= */ /* ========================================================== */ /* Conditions for getting Report-Variants and Stored-Searches */ /* ========================================================== */ if icForm = "" and icBusActivityCode = "" and icBusActivityLabel = "" and ilIncludeRepVarAndStoredSearches = true then do: /* ========================================================== */ /* Query the report variants that fit he BusComp/BusAct */ /* ========================================================== */ <Q-58 run ReportVariants (all) (Read) (NoCache) (input 0, (CompanyId) input 0, (UserID) input 0, (RoleID) input 0, (ReportID) input icBusComponentCode, (BusComponentCode) input icBusComponentLabel, (BusComponentLabel) output dataset tqReportVariants) in BReportVariant> for each tqReportVariants where not (tqReportVariants.tcRptRequestName = {&STOREDSEARCH-FACTORY-DEFAULT} or tqReportVariants.tcRptRequestName begins {&STOREDSEARCH-LAST-USED}) on error undo, throw : /* ======================================================================== */ /* Skip the records whererfore the required data of the layer is not filled */ /* ======================================================================== */ case iiLayerType: when {&CONTROLPROPERTYLAYERTYPE-USER} then if tqReportVariants.tiUsr_ID = 0 then next. when {&CONTROLPROPERTYLAYERTYPE-ROLE} then if tqReportVariants.tiRole_ID = 0 then next. when {&CONTROLPROPERTYLAYERTYPE-SYSTEM} then if tqReportVariants.tiUsr_ID <> 0 or tqReportVariants.tiRole_ID <> 0 then next. end case. /* case iiLayerType: */ /* ======================================================================== */ /* State the Layer */ /* ======================================================================== */ if tqReportVariants.tiUsr_ID = 0 then if tqReportVariants.tiRole_ID = 0 then assign viLayerType = {&CONTROLPROPERTYLAYERTYPE-SYSTEM} viLayerValue = 0. else assign viLayerType = {&CONTROLPROPERTYLAYERTYPE-ROLE} viLayerValue = tqReportVariants.tiRole_ID. else assign viLayerType = {&CONTROLPROPERTYLAYERTYPE-USER} viLayerValue = tqReportVariants.tiUsr_ID. /* ======================= */ /* Create an output record */ /* ======================= */ if not can-find (first tCustomisedLevels where tCustomisedLevels.tcBusComponentCode = tqReportVariants.tcBusComponentCode and tCustomisedLevels.tcBusActivityCode = tqReportVariants.tcBusActivityCode and tCustomisedLevels.tiLayerType = viLayerType and tCustomisedLevels.tiLayerValue = viLayerValue) then do: create tCustomisedLevels. assign tCustomisedLevels.tiLayerType = viLayerType tCustomisedLevels.tiLayerValue = viLayerValue tCustomisedLevels.tcBusComponentCode = tqReportVariants.tcBusComponentCode tCustomisedLevels.tcBusComponentLabel = tqReportVariants.tcBusComponentLabel tCustomisedLevels.tcBusActivityCode = tqReportVariants.tcBusActivityCode tCustomisedLevels.tcBusActivityLabel = tqReportVariants.tcBusActivityLabel tCustomisedLevels.tiBusActivityID = tqReportVariants.tiBusActivity_ID. end. /* if not can-find (first tCustomisedLevels where */ end. /* for each tqReportVariants where */ /* ========================================================== */ /* Query the stored searches */ /* ========================================================== */ <Q-97 run StoredSearchPrim (all) (Read) (NoCache) (input 0, (StoredSearchID) input '', (Name) input '', (LookupReference) input 0, (UsrId) input 0, (CompanyId) output dataset tqStoredSearchPrim) in BStoredSearch> for each tqStoredSearchPrim where num-entries(tqStoredSearchPrim.tcStoredSearchLookupRef,"/") = 2 and not (tqStoredSearchPrim.tcStoredSearchName = {&STOREDSEARCH-FACTORY-DEFAULT} or tqStoredSearchPrim.tcStoredSearchName begins {&STOREDSEARCH-LAST-USED}) on error undo, throw : /* ======================================================================== */ /* Skip the records whererfore the required data of the layer is not filled */ /* ======================================================================== */ case iiLayerType: when {&CONTROLPROPERTYLAYERTYPE-USER} then if tqStoredSearchPrim.tiUsr_ID = 0 then next. when {&CONTROLPROPERTYLAYERTYPE-ROLE} then if tqStoredSearchPrim.tiRole_ID = 0 then next. when {&CONTROLPROPERTYLAYERTYPE-SYSTEM} then if tqStoredSearchPrim.tiUsr_ID <> 0 or tqStoredSearchPrim.tiRole_ID <> 0 then next. end case. /* =================================== */ /* Get the BusCompof the stored-search */ /* =================================== */ <Q-98 run BusComponentPrim (all) (Read) (NoCache) (input 0, (BusComponentID) input entry(1,entry(2,tqStoredSearchPrim.tcStoredSearchLookupRef,'/'),'.'), (BusComponentCode) output dataset tqBusComponentPrim) in BBusinessComponent> find first tqBusComponentPrim where tqBusComponentPrim.tcBusComponentCode = entry(1,entry(2,tqStoredSearchPrim.tcStoredSearchLookupRef,'/'),'.') no-error. if available tqBusComponentPrim then do : /* ======================================================================== */ /* Skip the records whererfore the BusComp does not match */ /* ======================================================================== */ if icBusComponentCode <> "" and icBusComponentCode <> tqBusComponentPrim.tcBusComponentCode then next. if icBusComponentLabel <> "" and icBusComponentLabel <> tqBusComponentPrim.tcBusComponentLabel then next. /* ======================= */ /* Create an output record */ /* ======================= */ if tqStoredSearchPrim.tiUsr_ID = 0 then if tqStoredSearchPrim.tiRole_ID = 0 then assign viLayerType = {&CONTROLPROPERTYLAYERTYPE-SYSTEM} viLayerValue = 0. else assign viLayerType = {&CONTROLPROPERTYLAYERTYPE-ROLE} viLayerValue = tqStoredSearchPrim.tiRole_ID. else assign viLayerType = {&CONTROLPROPERTYLAYERTYPE-USER} viLayerValue = tqStoredSearchPrim.tiUsr_ID. if not can-find (first tCustomisedLevels where tCustomisedLevels.tcBusComponentCode = tqBusComponentPrim.tcBusComponentCode and tCustomisedLevels.tiLayerType = viLayerType and tCustomisedLevels.tiLayerValue = viLayerValue) then do: create tCustomisedLevels. assign tCustomisedLevels.tiLayerType = viLayerType tCustomisedLevels.tiLayerValue = viLayerValue tCustomisedLevels.tcBusComponentCode = tqBusComponentPrim.tcBusComponentCode tCustomisedLevels.tcBusComponentLabel = tqBusComponentPrim.tcBusComponentLabel tCustomisedLevels.tcBusActivityCode = "View" tCustomisedLevels.tcBusActivityLabel = "View". end. /* if not can-find (first tCustomisedLevels where */ end. /* if available tqBusComponentPrim */ end. /* for each tqStoredSearchPrim where */ end. /* if icForm = "" and */ /* ================================================================================================================== */ /* Go through all output records to fill LayerValueResolved that is a combination of the LayerType and the LayerValue */ /* ================================================================================================================== */ for each tCustomisedLevels on error undo, throw: case tCustomisedLevels.tiLayerType: when {&CONTROLPROPERTYLAYERTYPE-USER} then do: <Q-69 run UsrByIdLoginIsActNameLng (all) (Read) (Cache) (input tCustomisedLevels.tiLayerValue, (UsrId) input ?, (UsrLogin) input ?, (UsrIsActive) input ?, (UsrName) input ?, (LngId) output dataset tqUsrByIdLoginIsActNameLng) in BUser> find tqUsrByIdLoginIsActNameLng where tqUsrByIdLoginIsActNameLng.tiUsr_ID = tCustomisedLevels.tiLayerValue no-error. assign tCustomisedLevels.tcLayerValueResolved = if available tqUsrByIdLoginIsActNameLng then tqUsrByIdLoginIsActNameLng.tcUsrLogin + chr(2) + tqUsrByIdLoginIsActNameLng.tcUsrName else "". end. /* when {&CONTROLPROPERTYLAYERTYPE-USER} */ when {&CONTROLPROPERTYLAYERTYPE-ROLE} then do: <Q-37 run RolePrim (all) (Read) (Cache) (input tCustomisedLevels.tiLayerValue, (RoleID) input ?, (RoleName) output dataset tqRolePrim) in BRole> find tqRolePrim where tqRolePrim.tiRole_ID = tCustomisedLevels.tiLayerValue no-error. assign tCustomisedLevels.tcLayerValueResolved = if available tqRolePrim then tqRolePrim.tcRoleName else "". end. /* when {&CONTROLPROPERTYLAYERTYPE-ROLE} */ when {&CONTROLPROPERTYLAYERTYPE-SYSTEM} then assign tCustomisedLevels.tcLayerValueResolved = "". end case. end. /* for each tCustomisedLevels on error undo, throw: */