Param: IMetabaseObjectParam;
The Param property determines parameter of the current object, which values will be sent to opened object parameter.
Executing the example requires that the repository contains two regular reports with the REPORT and REPORT_ADD identifiers. The reports contain parameters.
The file system should contain the button image file D:\Work\Image\btn16x16.png.
Add links to the IO, Metabase, and Report system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
Report: IPrxReport;
UserBtn: IPrxUserButton;
OpenObjAction: IPrxUserButtonActionOpenObject;
ObjParam: IPrxOpenObjectParam;
Sheets: Array Of Integer;
Begin
Mb := MetabaseClass.Active;
Report := Mb.ItemById("REPORT").Edit As IPrxReport;
// Create a new custom button
UserBtn := Report.UserButtons.AddByType(PrxUserButtonType.OpenObject);
UserBtn.Name := "Open object";
// 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
OpenObjAction := UserBtn.Action As IPrxUserButtonActionOpenObject;
OpenObjAction.ObjectForOpen := Mb.ItemById("REPORT_ADD");
OpenObjAction.OpenInModal := True;
Sheets := New Integer[1];
Sheets[0] := 1;
OpenObjAction.SheetsForRefresh := Sheets;
// Set up parameters binding
ObjParam := OpenObjAction.Params.Item(0);
ObjParam.Type := PrxOpenObjectParamType.ReportParam;
(ObjParam.Control As IPrxOpenObjectReportParamControl).Param := Report.MetabaseObject.Params.Item(0);
// Save changes
(Report As IMetabaseObject).Save;
End Sub UserProc;
After executing the example a new custom button is created in the REPORT regular report. Name, image, and list of updated sheets will be set for the button. Object opening will be selected as a custom button action. Value of the current report parameter will be sent to the opened object parameter.
See also: