ItemById(Id: Integer): IPrxDocumentExpression;
ItemById(Id: Integer): Prognoz.Platform.Interop.Report.PrxDocumentExpression;
Id. Calculated field identifier.
The ItemById method returns parameters of calculated field by its identifier.
Calculated field identifier can be obtained in the IPrxDocumentExpression.Id property. Identifiers are generated automatically on creating calculated fields. The ItemById method is relevant for use, if there is a set of identifiers and there is no need to look over the entire collection by using the Item-Count properties.
Executing the example requires that the repository contains a regular report with the Report identifier. The text sheet named Document is created in the report, various calculated fields are used on this sheet.
Sub UserProc;
Var
MB: IMetabase;
Report: IPrxReport;
Doc: IPrxDocument;
Expressions: IPrxDocumentExpressions;
Expression: IPrxDocumentExpression;
i: Integer;
IdArray: IArrayList;
Begin
MB := MetabaseClass.Active;
Report := MB.ItemById("Report").Bind As IPrxReport;
Doc := Report.Sheets.FindByName("Document") As IPrxDocument;
Expressions := Doc.DocumentExpressions;
//...
//Selection of calculated fields identifiers by any attribute
//...
IdArray := New ArrayList.Create;
For i := 0 To Expressions.Count - 1 Do
Expression := Expressions.Item(i);
If <Calculated field selection condition> Then
//Save identifier to dynamic array
IdArray.Add(Expression.Id);
End If;
End For;
//...
//Get and work with selected calculated fields by their identifiers
//...
For i := 0 To IdArray.Count - 1 Do
Expression := Expressions.ItemById(IdArray.Item(i));
//...
End For;
End Sub UserProc;
The specified example shows in general how to get a collection of calculated fields, select the required calculated fields by any attribute and work with them further.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.ForeCollections;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Report;
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
Report: IPrxReport;
Doc: IPrxDocument;
Expressions: IPrxDocumentExpressions;
Expression: IPrxDocumentExpression;
i: Integer;
IdArray: IArrayList = New ArrayListClass();
Begin
MB := Params.Metabase;
Report := MB.ItemById["Report"].Bind() As IPrxReport;
Doc := Report.Sheets.FindByName("Document") As IPrxDocument;
Expressions := Doc.DocumentExpressions;
//...
//Selection of calculated fields identifiers by any attribute
//...
For i := 0 To Expressions.Count - 1 Do
Expression := Expressions.Item[i];
If <Calculated field selection condition> Then
//Save identifier to dynamic array
IdArray.Add(Expression.Id);
End If;
End For;
//...
//Work with selected calculated fields
//...
For i := 0 To IdArray.Count - 1 Do
Expression := Expressions.ItemById(IdArray.Item[i] As Integer);
//...
End For;
End Sub;
See also: