IRdsDictionaryBatchUpdate.SetData

Fore Syntax

SetData(Data: IRdsDictionaryElementData);

Fore.NET Syntax

SetData(Data: Prognoz.Platform.Interop.Rds.IRdsDictionaryElementData);

Parameters

Data. Updated data.

Description

The SetData method sets data to be updated.

Comments

Use the IRdsDictionaryElements.CreateData method to get MDM dictionary data.

Fore Example

Executing the example requires that the repository contains a table MDM dictionary with the DICT identifier.

Add links to the Metabase, Rds system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    RdsDictObj: IMetabaseObject;
    RdsDict: IRdsDictionary;
    DictInst: IRdsDictionaryInstance;
    Batch: IRdsDictionaryBatchUpdate;
    Attr: IRdsAttribute;
    data: IRdsDictionaryElementData;
    Filters: IRdsDictionaryFilterConditions;
Begin
    // Get current repository
    mb := MetabaseClass.Active;
    // Get dictionary
    RdsDictObj := mb.ItemById("DICT_COPY1").Edit;
    DictInst := RdsDictObj.Open(NullAs IRdsDictionaryInstance;
    
// Create package to update elements
    batch := DictInst.CreateBatch(RdsDictionaryBatchType.Update) As IRdsDictionaryBatchUpdate;
    data := DictInst.Elements.CreateData;
    RdsDict := RdsDictObj 
As IRdsDictionary;
    
// Select dictionary attribute
    Attr := RdsDict.Attributes.FindById("NAME");
    
// Filter dictionary elements by selected attribute
    Filters := batch.Filter;
    
If Filters.FindByAttribute(Attr) <> Null Then
        Filters.Clear;
    
End If;
    
// Determine new value for elements by selected attribute
    data.Value(data.AttributeIndex(Attr.Key)) := "Element " + DateTime.Now.ToString;
    
// Refresh data
    batch.SetData(data);
    batch.Execute;
End Sub UserProc;

After executing the example names of all elements in the DICT dictionary are changed.

Fore.NET Example

The requirements and result of the Fore.NET Example execution match with those in the Fore Example.

Imports Prognoz.Platform.Interop.Rds;

Public Shared Sub Main(Params: StartParams);
Var
    mb: IMetabase;
    RdsDictObj: IMetabaseObject;
    RdsDict: IRdsDictionary;
    DictInst: IRdsDictionaryInstance;
    Batch: IRdsDictionaryBatchUpdate;
    Attr: IRdsAttribute;
    data: IRdsDictionaryElementData;
    Filters: IRdsDictionaryFilterConditions;
Begin
    // Get current repository
    mb := Params.Metabase;
    // Get dictionary
    RdsDictObj := mb.ItemById["DICT_COPY1"].Edit();
    DictInst := RdsDictObj.Open(
NullAs IRdsDictionaryInstance;
    
// Create package to update elements
    batch := DictInst.CreateBatch(RdsDictionaryBatchType.rdbtUpdate) As IRdsDictionaryBatchUpdate;
    data := DictInst.Elements.CreateData();
    RdsDict := RdsDictObj 
As IRdsDictionary;
    
// Select dictionary attribute
    Attr := RdsDict.Attributes.FindById("NAME");
    
// Filter dictionary elements by selected attribute
    Filters := batch.Filter;
    
If Filters.FindByAttribute(Attr) <> Null Then
        Filters.Clear();
    
End If;
    
// Determine new value for elements by selected attribute
    data.Value[data.AttributeIndex[Attr.Key]] := "Element " + DateTime.Now.ToString();
    
// Refresh data

    batch.SetData(data);
    batch.Execute();        
End Sub;

See also:

IRdsDictionaryBatchUpdate