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
39
40
41
42
43
44
45
Quintiq file version 2.0
#parent: #root
StaticMethod ValidateInput (
  output String feedback_o,
  output String sanitycheckfeedback_o,
  MacroPlan macroplan,
  String name,
  SalesSegment_MP salessegment,
  Boolean checkuniquename
) declarative remote as Boolean
{
  Description: 'Validate user input on for sales segment in the Designer.'
  TextBody:
  [*
    feedback_o := '';
    sanitycheckfeedback_o := '';
    
    // Get the maximum length limit of names
    namelengthlimit := GlobalParameters_MP::GetLengthOfNames();
    subname := MacroPlan::GetSubstituteName( name );
    
    // Get formatted instance name
    instance := Translations::MP_SalesSegment_Instance( subname );
    
    // Check if name is unique
    if( checkuniquename
        and exists( macroplan, SalesSegment_MP, segment,
                    salessegment <> segment,
                    segment.Name() = name ) )
    {
      feedback_o := SanityCheckMessage::GetFormattedMessage( instance,
                                                             Translations::MP_SalesSegment_ValidateInput_IsNotUnique() );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Check if the name is valid or is within the allowed length
    else if( name = '' or name.Length() > namelengthlimit )
    {
      feedback_o := SanityCheckMessage::GetFormattedMessage( instance,
                                                             Translations::MP_SalesSegment_ValidateInput_IsNameEmptyOrExceedLengthLimit( namelengthlimit ) );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
    }
    
    return feedback_o = '';
  *]
}