yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
Quintiq file version 2.0
#parent: #root
StaticMethod CanSave (KpiLabel owner, KpiLabelValue existing, String value) as Boolean
{
  Description: 'Checks to see if a KpiLabelValue can be saved like this. Used in preconditions. Sets the FeedbackObject.'
  TextBody:
  [*
    val      := value.TrimBoth();
    feedback := FeedbackObject::LocalFeedback();
    isUnique := not exists( owner, Value, v, ( isnull( existing ) or existing <> v )
                                          and  v.Value() = val );
    
    if ( not feedback.CheckHard( isUnique ) )
    {
      feedback.AddHard( Translations::Kpi_LabelValue_NameMustBeUnique( val ) );  
    }
    
    if ( not feedback.CheckHard( val <> '' ) )
    {
      feedback.AddHard( Translations::Kpi_LabelValue_NameCantBeEmpty() );
    }
    
    return feedback.IsAllowed();
  *]
}