Update other records values based on last record input

Update other records values based on last record input

Hello Community, 

Maybe a simple question for you guys, but I'm struggling with the following use case. 
We need to ensure we have only Approved Supplier which we can deal with. Those approvals are based on evaluation and qualification as shown in the illustration below. 

The example shows historical qualifications for the same supplier, and whatever the Qualification Status is, it is always the latest date that counts to show this supplier as approved. Therefor I'm using the "LATEST" column to filter my report with only approved suppliers. 

The issue I have is to ensure that when there's a new qualification (so a new record) with a more recent date, I would like all the history of "LATEST" to get the value "OLD"

I'm using the following script but does not seem to help. Any idea of what I'm doing wrong ?

  1. for each  rec in NEW_QUALIFICATION[QUALIFICATION_DATE > input.QUALIFICATION_DATE && SUPPLIER_NAME = input.SUPPLIER_NAME]
  2. {
  3. rec.LATEST="OLD";
  4. }