IMetabaseUpdateDataObjectNode.FieldsOnly

Syntax

FieldsOnly: IStringList

FieldsOnly: System.Collections.Generic.IList

Description

The FieldsOnly property determines a list of fields or attributes for update.

Comments

The property is not set by default, all table fields or dictionary attributes are updated on update installation. The data update method is determined by the IMetabaseUpdateDataObjectNode.BatchMode property.

To update specific fields or attributes, specify their identifiers in the FieldsOnly property. The specified fields or attributes will be updated on update installation for all table records or dictionary elements in accordance with the selected object data update method.

To update specific records or elements, use the IMetabaseUpdateDataObjectNode.PrimaryKeysOnly property.

TIP. If new table records or dictionary elements have been added, you should update all fields or attributes. During the update, all data fields or attributes from the update will be enough to fill in mandatory fields or attributes in the repository to be updated.

Example

Executing the example requires an MDM repository with the REP_NSI identifier containing an MDM dictionary with the DICT_1 identifier. It is assumed that the MDM dictionary contains standard attributes ATTR4, ATTR5, dictionary elements with the 1, 2 keys.

Add links to the system assemblies:

Sub UserProc;
Var
    Mb: IMetabase;
    MUpdate: IMetabaseUpdate;
    RootFolder: IMetabaseUpdateFolderNode;
    Node: IMetabaseUpdateDataObjectNode;
Begin
    
//Determine the current repository
    Mb := MetabaseClass.Active;
    
//Open update manager to create a new update
    MUpdate := Mb.CreateUpdate;
    
//Create an update structure
    RootFolder := MUpdate.RootFolder;
    Node := RootFolder.Add(MetabaseUpdateNodeType.DataObject) 
As IMetabaseUpdateDataObjectNode;
    //Determine an object update method 
    Node.BatchMode := ObjectUpdateDataBatchMode.UpdateInsert;
    
//Get object (MDM dictionary) located in container object (MDM repository)
    Node.Object := Mb.ItemByIdNamespace("DICT_1", Mb.ItemById("REP_NSI").Key).Bind;
    
//Determine an object data update method 
    Node.UpdatePart := MetabaseObjectUpdatePart.DataMetadata;
    
//Enumerate dictionary attributes to be updated
    Node.FieldsOnly.Add("ATTR4");
    
Node.FieldsOnly.Add("ATTR5");
    //Enumerate dictionary elements to be updated
    Node.PrimaryKeysOnly.Add(1Null);
    Node.PrimaryKeysOnly.Add(
2Null);
    
//Determine a full path and file name, to which update will be saved
    MUpdate.SaveToFileNF("C:\Dict_1.pefx");
End Sub UserProc;

Imports System;
Imports Prognoz.Platform.Interop.Metabase;

Public Shared Sub Main(Params: StartParams);
Var
    Mb: IMetabase;
    MUpdate: IMetabaseUpdate;
    RootFolder: IMetabaseUpdateFolderNode;
    Node: IMetabaseUpdateDataObjectNode;
Begin
    
//Determine the current repository
    Mb := Params.Metabase;
    
//Open update manager to create a new update
    MUpdate := Mb.CreateUpdate();
    
//Create an update structure from one object
    RootFolder := MUpdate.RootFolder;
    Node := RootFolder.Add(MetabaseUpdateNodeType.untDataObject) 
As IMetabaseUpdateDataObjectNode;
    
//Determine an object update method - object data will be updated and appended with new records
    Node.BatchMode := ObjectUpdateDataBatchMode.obupdabamoUpdateInsert;
    
//Get object (MDM dictionary) located in container object (MDM repository)
    Node.Object := Mb.ItemByIdNamespace["DICT_1", Mb.ItemById["REP_NSI"].Key].Bind();
    
//Determine an object data update method - object data and metadata will be updated
    Node.UpdatePart := MetabaseObjectUpdatePart.moupDataMetadata;
    
//Enumerate dictionary attributes to be updated
    Node.FieldsOnly.Add("ATTR4");
    Node.FieldsOnly.Add(
"ATTR5");
    //Enumerate dictionary elements to be updated
    Node.PrimaryKeysOnly.Add(1Null);
    Node.PrimaryKeysOnly.Add(
2Null);
    
//Determine a full path and file name, to which update will be saved.
    MUpdate.SaveToFileNF("C:\Dict_1.pefx");
End Sub;

After executing the example a new update is created. The update file will be located in the specified folder. The ATTR4, ATTR5 attributes of the elements with the 1, 2 keys of the DICT_1 MDM dictionary will be included in the update. Only the ATTR4, ATTR5 attributes of the dictionary elements with the 1, 2 keys will be updated. The rest of the attributes and elements will not be updated.

See also:

IMetabaseUpdateDataObjectNode