admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Quintiq file version 2.0
#parent: #root
Method GetEntitiesByName (
  String name_fragment,
  output owning Units units_o,
  output owning StockingPoint_MPs sps_o
) remote as owning Entitys
{
  Description: 'Return a series of keys for stocking point & unit with matching name.'
  TextBody:
  [*
    // TYG2 JAN-11-2017 (created)
    
    entities := null( Entitys, owning );
    units_o := null( Units, owning );
    sps_o := null( StockingPoint_MPs, owning );
    
    if( name_fragment <> '' )
    {
      name_fragment := name_fragment.ToLower();
      
      entities := selectsortedset( this, Entity, e, 
                                   e.DisplayName().ToLower().FindString( name_fragment, 0 ) > -1
                                   and guard( not e.astype( StockingPoint_MP ).IsSystem(), true ),
                                   // Sort it decending by DsiplayIndex as workaround for ScrollToSelectedElement in List
                                   -e.DisplayIndex() );
               
      //assign the units and sp instances before searching for their parents.
      units_o := selectset( entities, Elements.astype( Unit ), u, true );
      sps_o := selectset( entities, Elements.astype( StockingPoint_MP ), sp, true )
      
      parents := Entity::GetAllParents( entities );
      entities := entities.Union( parents );                                   
    }
    
    return &entities;
  *]
}