| Quintiq file version 2.0 | 
| #parent: #root | 
| Method PanelSearchSalesSegments () id:Method_ApplicationLibMacroPlanner_PanelSearchSalesSegments | 
| { | 
|   #keys: '[113694.2.1027606231]' | 
|   Body: | 
|   [* | 
|     // Search sales segments by string, highlight & select the instances in the list. | 
|     if( not isnull( MacroPlan ) ) | 
|     { | 
|       filter := 'true'; | 
|        | 
|       if( EditorSearchSalesSegments.Text() <> '' ) | 
|       { | 
|         salessegments := MacroPlan.GetSalesSegmentsByName( EditorSearchSalesSegments.Text() ); | 
|          | 
|         if( salessegments.Size() < 1000 ) // Performance cap | 
|         { | 
|           DataHolderSalesSegments.Data( salessegments.Copy() ); | 
|            | 
|           // Using recursive IsParentin filter is very expensive, so we add the parent to the dataholder and do a simpel exists filter | 
|           sswithparents := SalesSegment_MP::GetAllParents( salessegments ); | 
|           sswithparents := sswithparents.Union( salessegments ); | 
|           DataHolderSearchSalesSegment.Data( sswithparents.Copy() ); | 
|          | 
|           filter := 'exists( dataholdersearchsalessegment, Elements, e, e = object )'; | 
|         }       | 
|       } | 
|       GUIDataSetLevelSalesSegment.FixedFilter( filter );  | 
|     } | 
|   *] | 
| } |