Value Tree on multiple levels

Understanding basics of 1C:Enterprise platform. To start working with 1C:Enterprise platform visit Getting started page

#1
People who like this:0Yes/0No
Active user
Rating: 4
Joined: Sep 1, 2014
Company: Smart ID Dynamics

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.

 
#2
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

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");

Download 1.png (10.26 KB)
Download 2.png (4.39 KB)
 
#3
People who like this:0Yes/0No
Active user
Rating: 4
Joined: Sep 1, 2014
Company: Smart ID Dynamics

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.

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.