| 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; | 
|   *] | 
| } |