Wednesday, July 3, 2013

Cross company traversing

Today's discussion is around traversing a table across companies. In our example, a record sits in a custom parameters table, which needs to be updated. Instinctively first thing to check would be  the SaveDataPerCompany property of the table, which in our case is set to Yes. So this table stores records per company and for implementing the feature in discussion we will forcefully update the record across all companies by overriding the table's update method.

Logic centers around
1. Traversing DataArea table, which is a system table containing all legal entities
2. Using keyword changeCompany which swaps the companies one by one and
3. Clearing the table object after each change, failing to do so makes the logic not work.

 public void update()   
 {   
   YourTable yourtable;  
   DataArea DataArea;   
   super();   
   while select DataArea where !DataArea.isVirtual   
   {   
     changecompany (DataArea.Id)   
     {   
       yourtable= null;   
       ttsBegin;   
       yourtable= Yourtable::find(true);        
       if (yourtable.RecId)   
       {   
         yourtable.Field = "";   
         yourtable.update();   
       }   
       ttsCommit;   
     }   
   }   
 }  

1 comment:

  1. What is a casino? - JT Hub
    A casino game with a simple design and 안성 출장마사지 layout. 서산 출장안마 But for every 5 cents, 화성 출장안마 you'll earn as 성남 출장샵 much as your 나주 출장샵 favorite games. In fact, if you

    ReplyDelete