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
Quintiq file version 2.0
#parent: #root
StaticMethod FindOrCreateByName (LibOpt_Optimization owner, String groupname) as LibOpt_Group
{
  Description: 'Find or create the `LibOpt_Group` by providing its unique name.'
  TextBody:
  [*
    group := LibOpt_Group::FindLibOpt_Group_ByName( groupname );
    if( isnull( group ) )
    {
      // If the type index is looking in the wrong dataset
      group := select( owner, Group, g, g.Name() = groupname );
      
      if( isnull( group ) )
      {
        group := owner.Group( relnew,
                              ID := maxvalue( max( owner, Group, gp, true, gp.ID() ), 0 ) + 1,
                              Name := groupname );
      }
    } 
    
    return group;
  *]
}