Desktop version

Main > Forum > 1C:Enterprise Platform > Studying 1C:Enterprise platform > Value Tree on multiple levels

Forum

Search UsersRules
Value Tree on multiple levels
#1
Active user
Points:: 0
Joined:: Sep 1, 2014

I have this function:

Code
&AtServer
Function StockDisplay (This)
   
   ConvertedValueTree = FormAttributeToValue("StocksTree");
   ConvertedValueTree.Rows.Clear();
   
   
   Frunze = DisplayStockFunctionsV2.GetAllArticlesWithStockFromSpecifiedLocation(This.Code);
   
   ArticoleStockGeneral = DisplayStockFunctionsV2.SearchForAllArticleStock(This, Frunze); //ValueTable   
   n = ArticoleStockGeneral.Count();
   
   For i=0 To n-1 Do
      
      NewRow = ConvertedValueTree.Rows.Add();
      NewRow.Name = ArticoleStockGeneral[i].Article.Description;
      NewRow.TotalStock = ArticoleStockGeneral[i].Stock;
      
      ListaLocatii = DisplayStockFunctionsV2.SearchForAllArticleLocations(This, ArticoleStockGeneral[i].Article);
      m =  ListaLocatii.Count();
      For j=0 To m-1 Do
         NewRow_1 = NewRow.Locations.Rows.Add();
         NewRow_1.Name = ListaLocatii[j].Value.Description; 
         
         DetaliiStock = DisplayStockFunctionsV2.SearchForArticleDetailedStock(ListaLocatii[j].Value.Ref, ArticoleStockGeneral[i].Article);
         NewRow_1.Stock = DetaliiStock.Total("Qty");
         
         p = DetaliiStock.Count();
         For k=0 To p-1 DO
            
            NewRow_2 = NewRow_1.StockInputs.Rows.Add();
            NewRow_2.Date = DetaliiStock[k].Date;
            NewRow_2.Quantity = DetaliiStock[k].Qty;

         EndDo;
      EndDO;
   EndDo;
   
   ValueToFormAttribute(ConvertedValueTree, "StocksTree");
   
   
EndFunction



Atached image contains value tree definition on form.

But NewRow_1.Name and all columns from Locations which is Value Tree type are not recognized and i receive an error when I try to add rows on Locations.

Profile
#2
Guest
Points::
Joined::

Hello, Marius Gidu!

Unfortunately, your structure is not supported. I can suggest you to change the way you keep your data. For this, use the single value tree and add subrows. I created an example for you:

Code
   StocksTreeValue = FormAttributeToValue("StocksTree");
   
   NewStock = StocksTreeValue.Rows.Add();
   NewStock.Name = NStr("en = 'Stock'");
   NewStock.TotalStock = 100;
   
   NewLocation = NewStock.Rows.Add();
   NewLocation.Name = NStr("en = 'Location'");
   NewLocation.Stock = 18;
   NewLocation.IsLocation = True;
   
   NewStockInput = NewLocation.Rows.Add();
   NewStockInput.Date = CurrentSessionDate();
   NewStockInput.Quantity = 4;
   NewStockInput.IsStockInput = True;
   
   ValueToFormAttribute(StocksTreeValue, "StocksTree");

Profile
#3
Active user
Points:: 0
Joined:: Sep 1, 2014

Thanks.
I realized that in this manner wouldn`t work so I just resolved same as in your example.

Thanks a lot for your answer.

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.