Parameters: IDefParameters;
The Parameters property returns the collection of data entry form parameters.
Executing the example requires that the repository contains dictionaries with the DICT_FIRMS and DICT_INDICATORS identifiers. It is also required to be a data entry form, for which the specified macro is set as an executable method for a custom button.
Add links to the Dimensions, Metabase, Report system assemblies. Add links to the assemblies required for working with data entry forms.
Public Sub AddParameters(Report: IPrxReport);
Var
Mb: IMetabase;
Dict: IMetabaseObjectDescriptor;
DEForm: IDataEntryForm;
Params: IDefParameters;
Param1, Param2: IDefParameter;
Sheets: NamedEntitiesCollection;
Sheet: IPrxSheet;
Result: IDefParametersApplyResult;
Begin
Mb := MetabaseClass.Active;
// The current data entry form instance
DEForm := New DataEntryForm.CreateByReport(report);
//Parameters
Params := DEForm.Parameters;
Params.BeginUpdate;
//Create new parameters
Param1 := Params.Add;
Param1.Name := "Parameter 1";
Dict := Mb.ItemById("DICT_FIRMS");
Param1.Dictionary := New NamedEntity.CreateWithData(Dict.Key, Dict.Name, Dict.Id);
Param1.SelectionType := SelectionTypeEnum.Single;
Param1.UseDefaultValue := True;
Param1.DefaultValueSelection.SelectElement(1, False);
Param1.IncludeAllSheets;
Param2 := Params.Add;
Param2.Name := "Parameter 2";
Dict := Mb.ItemById("DICT_INDICATORS");
Param2.Dictionary := New NamedEntity.CreateWithData(Dict.Key, Dict.Name, Dict.Id);
Param2.SelectionType := SelectionTypeEnum.Multi;
Param2.UseDefaultValue := True;
Param2.DefaultValueSelection.SelectElement(1, False);
//Data entry form page, on which parameter will be available
Sheet := DEForm.Sheets.Item(0);
Sheets := New NamedEntitiesCollection.Create;
Sheets.Add(New NamedEntity.CreateWithData(Sheet.Key, Sheet.Name, Sheet.Name));
Param2.Sheets := Sheets;
//Apply changes
Result := Params.ApplyChanges;
If Result.Success Then
Debug.WriteLine("Parameters are created without errors")
Else
Debug.WriteLine(Result.Title);
Debug.WriteLine(Result.Message);
Debug.WriteLine("Parameter key: " + Result.ParamKey.ToString);
End If;
DEForm._Dispose;
End Sub AddParameters;
After the macro is executed, two parameters are created and set up. Parameters will work with the specified repository dictionaries.
See also: