Param: IMetabaseObjectParam;
The Param property determines the current object parameter, which values will be sent to calculation algorithm parameter.
The parameter should be created based on repository dictionary.
Executing the example requires that the repository contains a regular report with the REPORT identifier and a calculation algorithm with the ALGORITHM identifier. The algorithm and the parameter contain the parameter based on the same repository dictionary.
The file system should contain the D:\Work\Image\btn16x16.png image for a button.
Add links to the Express, IO, Metabase and Report system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
Report: IPrxReport;
UserBtn: IPrxUserButton;
AlgAction: IPrxUserButtonActionAlgorithm;
AlgParam: IAlgorithmParam;
ParamControl: IAlgorithmObjectParamControl;
Begin
Mb := MetabaseClass.Active;
Report := Mb.ItemById("REPORT").Edit As IPrxReport;
// Create a new custom button
UserBtn := Report.UserButtons.AddByType(PrxUserButtonType.Algorithm);
UserBtn.Name := "Start algorithm";
// Set up custom button
UserBtn.Icon := New FileStream.Create("D:\Work\Image\btn16x16.png", FileOpenMode.Read, FileShare.DenyNone);
UserBtn.IconType := "png";
UserBtn.SmallIcon := False;
// Set up actions
AlgAction := UserBtn.Action As IPrxUserButtonActionAlgorithm;
AlgAction.Algorithm := Mb.ItemById("ALGORITHM");
AlgParam := AlgAction.Params.Item(0);
AlgParam.Type := AlgorithmParamType.ObjectParam;
ParamControl := AlgParam.Control As IAlgorithmObjectParamControl;
ParamControl.Param := Report.MetabaseObject.Params.FindById("ITEM1");
ParamControl.AttributeId := "KEY";
ParamControl.SelectionType := AlgorithmParamSelectionType.First;
// Save changes
(Report As IMetabaseObject).Save;
End Sub UserProc;
After executing the example a custom button is created in the regular report. Name and image will be set for the button. Algorithm calculation will be selected as a custom button action. Value of the KEY attribute of the first element selected in regular report parameter will be sent to calculation algorithm parameter.
See also: