project BLF > class BControlProperty > method ApiSaveViewSettings
Description
save customisation of a single view on a single grid
Parameters
icWindow | input | character | |
icBusinessComponentCode | input | character | |
icActivityCode | input | character | |
icRoleName | input | character | |
icControlName | input | character | control name = grid name |
icViewName | input | character | |
icViewProperties | input | character | all properties, concatenated into a single string |
iiLayerType | input | integer | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program3/bcontrolproperty.p)
if oiReturnStatus = 0
then assign oiReturnStatus = -98.
assign viLayerType = if vcUserLogin = "FacDef"
then {&CONTROLPROPERTYLAYERTYPE-SYSTEM}
else iiLayerType
vlSaveViewSettings = yes.
case viLayerType:
when {&CONTROLPROPERTYLAYERTYPE-SYSTEM}
then assign viLayerValue = 0.
when {&CONTROLPROPERTYLAYERTYPE-ROLE}
then do:
if icRoleName = ? or
icRoleName = ""
then assign viLayerValue = 0.
else do:
<Q-8 run RolePrim (all) (Read) (NoCache)
(input ?, (RoleID)
input icRoleName, (RoleName)
output dataset tqRolePrim) in BRole >
find tqRolePrim where
tqRolePrim.tcRoleName = icRoleName
no-error.
assign viLayerValue = if available tqRolePrim
then tqRolePrim.tiRole_ID
else 0.
end.
end.
when {&CONTROLPROPERTYLAYERTYPE-USER}
then assign viLayerValue = viUsrId.
end.
<M-1 run DataLoadByWindowActivity
(input icWindow (icWindow),
input icBusinessComponentCode (icBusinessComponentCode),
input icActivityCode (icActivityCode),
input icRoleName (icRoleName),
input '' (icUserLogin),
input viLayerType (iiLayerType),
input false (ilIncludeLowerLevels),
output viFcReturnSuper (oiReturnStatus)) in BControlProperty>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
find first tControlProperty where
tControlProperty.ControlPropertyWindow = icWindow and
tControlProperty.ControlPropertyControl = icControlName and
tControlProperty.ControlPropertyName = icViewName and
tControlProperty.ControlPropertyLayerType = viLayerType and
tControlProperty.ControlPropertyLayerValue = viLayerValue
no-error.
if available tControlProperty
then assign tControlProperty.tc_Status = if icViewProperties = ? or
icViewProperties = ""
then "D"
else "C".
else
if icViewProperties <> ? and
icViewProperties <> ""
then do:
<M-2 run AddDetailLine
(input 'ControlProperty' (icTable),
input '' (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BControlProperty>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
assign tControlProperty.tcBusActivityCode = icActivityCode
tControlProperty.tcBusComponentCode = icBusinessComponentCode
tControlProperty.ControlPropertyName = icViewName
tControlProperty.ControlPropertyWindow = icWindow
tControlProperty.ControlPropertyControl = icControlName
tControlProperty.ControlPropertyLayerType = viLayerType
tControlProperty.ControlPropertyLayerValue = viLayerValue.
end.
if icViewProperties <> ? and
icViewProperties <> ""
then do:
if length(icViewProperties, "RAW") <= 10
then assign tControlProperty.ControlPropertyValue = icViewProperties.
else do:
/* Break the ControlPropertyValue up in segments */
assign tControlProperty.ControlPropertyValue = "".
/* Check if there already exists a segment else create one */
find first tControlPropertySegment where
tControlPropertySegment.tc_ParentRowid = tControlProperty.tc_Rowid and
tControlPropertySegment.ControlPropertySegmentSeq = 1
no-error.
if available tControlPropertySegment
then assign tControlPropertySegment.tc_Status = "C".
else do:
<M-5 run AddDetailLine
(input 'ControlPropertySegment' (icTable),
input tControlProperty.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BControlProperty>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
assign tControlPropertySegment.ControlPropertySegmentSeq = 1.
end.
assign tControlPropertySegment.ControlPropertySegmentText = icViewProperties
viSegment = 1.
do while length(tControlPropertySegment.ControlPropertySegmentText, "RAW") > 4000:
assign vcControlPropertyValuePart = substr(tControlPropertySegment.ControlPropertySegmentText, 4001, -1, "RAW")
tControlPropertySegment.ControlPropertySegmentText = substr(tControlPropertySegment.ControlPropertySegmentText, 1, 4000, "RAW")
viSegment = viSegment + 1.
/* Check if there already exists a segment else create one */
find first tControlPropertySegment where
tControlPropertySegment.tc_ParentRowid = tControlProperty.tc_Rowid and
tControlPropertySegment.ControlPropertySegmentSeq = viSegment
no-error.
if available tControlPropertySegment
then assign tControlPropertySegment.tc_Status = "C".
else do:
<M-6 run AddDetailLine
(input 'ControlPropertySegment' (icTable),
input tControlProperty.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BControlProperty>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
assign tControlPropertySegment.ControlPropertySegmentSeq = viSegment.
end.
assign tControlPropertySegment.ControlPropertySegmentText = vcControlPropertyValuePart.
end.
end.
for each tControlPropertySegment where
tControlPropertySegment.tc_ParentRowid = tControlProperty.tc_Rowid and
tControlPropertySegment.ControlPropertySegmentSeq > viSegment:
assign tControlPropertySegment.tc_Status = "D".
end.
end.
<M-3 run ValidateBC (output viFcReturnSuper (oiReturnStatus)) in BControlProperty>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
<M-7 run AdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BControlProperty>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
<M-4 run DataSave (output viFcReturnSuper (oiReturnStatus)) in BControlProperty>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
if oiReturnStatus = -98
then assign 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 = "BControlProperty".
create ttContext.
assign ttContext.propertyName = "methodName"
ttContext.propertyValue = "ApiSaveViewSettings".
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/bcontrolproperty.apisaveviewsettings.i.xsd", ?).
vhParameter = vhInputDS:get-buffer-handle("tParameterI").
vhParameter:buffer-create().
assign vhParameter::icWindow = <parameter value>
vhParameter::icBusinessComponentCode = <parameter value>
vhParameter::icActivityCode = <parameter value>
vhParameter::icRoleName = <parameter value>
vhParameter::icControlName = <parameter value>
vhParameter::icViewName = <parameter value>
vhParameter::icViewProperties = <parameter value>
vhParameter::iiLayerType = <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.