| Quintiq file version 2.0 | 
| #parent: #root | 
| Method CreateRetentionPeriodPolicy | 
| { | 
|   Description: 'Create retentionperiod policy base on setting on kpitrackersetting' | 
|   TextBody: | 
|   [* | 
|     if ( not ( isnull( this.KPITrackerSetting_tobedeleted_2022_3() ) or this.KPITrackerSetting_tobedeleted_2022_3().IsInactive() ) ) | 
|     { | 
|       retentionduration := this.KPITrackerSetting_tobedeleted_2022_3().RetentionDuration(); | 
|       opt := DatasetFindOptions::Construct( KpiModelExtensions::GetKpiTrackerDatasetName() ); | 
|       mds := MDSKpiTracker::Find( opt ); | 
|        | 
|       mds->( kpitracker ) | 
|       { | 
|         policy := select( kpitracker, RetentionPolicy.astype( KpiPeriodRetentionPolicy ), krp, true ); | 
|         // Create new policy if cannot find one | 
|         if ( isnull( policy ) ) | 
|         { | 
|           policy := kpitracker.RetentionPolicy( relnew, KpiPeriodRetentionPolicy, Identification := SMKpiSnapshotGenerator::KPISnapshotRetentionPolicyID() );   | 
|         } | 
|          | 
|         policy.RetentionPeriod( retentionduration ); | 
|       } | 
|     } | 
|   *] | 
|   InterfaceProperties { Accessibility: 'Module' } | 
| } |