| Quintiq file version 2.0 | 
| #parent: #root | 
| Method RefreshUIIsLastAttribute ( | 
|   shadow[KpiSnapshotSetData] queryResult, | 
|   KpiLabel series, | 
|   structured[KpiMetaData] metadatas, | 
|   Boolean isLastSnapshotChecked | 
| ) id:Method_GlobalStateKpiTracker_RefreshUIIsLastAttribute | 
| { | 
|   #keys: '[146874.0.1589192524]' | 
|   Body: | 
|   [* | 
|     // Updates the UI_IsLast attribute of the KpiValues to match the selected series / kpi. | 
|     // Call this method after updating the 'UI_LabelValue' attribute. | 
|      | 
|     // First clean previously set flags. | 
|     traverse( queryResult, SnapshotData.Value, v, v.UI_IsLast() ) | 
|     { | 
|       v.UI_IsLast( false ); | 
|     } | 
|      | 
|     // Now, if the checkbox is checked and a Series has been selected, | 
|     // determine which KpiValue objects represent the LAST snapshot of their | 
|     // KPI & LabelValue of the selected Series (= Label) | 
|     if( isLastSnapshotChecked and not isnull( series ) and not isnull( queryResult ) ) | 
|     { | 
|       traverse( series, Value, serieValue ) | 
|       { | 
|         traverse( metadatas, Elements, kpi ) | 
|         { | 
|             lastValue := maxselect( queryResult, SnapshotData.Value, v, | 
|                                     v.UI_LabelValue() = serieValue.Value() and | 
|                                     v.Name() = kpi.Name(), | 
|                                     v.UI_DateTime() ); | 
|             if( not isnull( lastValue ) ) | 
|             { | 
|               lastValue.UI_IsLast( true ); | 
|             } | 
|      | 
|      | 
|         } | 
|       } | 
|     } | 
|   *] | 
| } |