FNCPlanner AddOrUpdate doesn't really work

FNCPlanner.AddOrUpdate doesn't really seem to work.

There are some examples in the documentation. But these all refer to creating NEW entries. My understanding of an "AddOrUpdate" is, that the FNCPlanner detects whether an item already exists or not, and responds accordingly (add, or update). The existing items all have a unique ID or a DBKey. When I call my function, new items are added with each update of the scheduler, so that after a short time I always have the same items side by side in the plan. So "addOrUpdate" doesn't seem to work like that. Here is a piece of my function:

if aItem.apt_vehicle.veh_planner.ValueOrDefault>0 then
begin
txt:='Item-Id: '+aItem.id.toString+#13; //<-- this line only to check the ID
for aItemEntry in aItem.apt_entries do
begin
txt:=txt+FormatDateTime('(hh:nn) ',aItemEntry.ae_pickuptime.Value)
+aItemEntry.ae_person+#13;
end;
dayPlanner.BeginUpdate;
with dayPlanner.AddOrUpdateItem(aItem.apt_vehicle.veh_planner.Value,
aItem.apt_starttime,
aItem.apt_endtime,
aItem.apt_reason.ValueOrDefault,
txt,aItem.id) do
begin
Color:= ColorAdjustLuma(colorToRGB($00408000),150,false);
TitleColor:= ColorAdjustLuma(colorToRGB($00408000),10,false);
FontColor:= clBlack;
dbKey:=aItem.id.ToString;
editable:=false;
selectable:=true;
end;
dayPlanner.EndUpdate;
end;

What shoud I do?

I have found a solution to my problem. Here is an excerpt from the source code:

  dayPlanner.BeginUpdate;
  with dayPlanner do
    begin
      item:=FindItemWithDBKey(aItem.id.ToString);
      if item=nil then
        item:=items.Add;
      with item do
        begin
          dbKey:=aItem.id.ToString;
          starttime:=aItem.apt_starttime;
          endtime:=aItem.apt_endtime;
          resource:=aItem.apt_vehicle.veh_planner.Value;
          title:=aItem.apt_reason.ValueOrDefault;
          text:=txt;
          ....
        end;
    end;
 dayPlanner.EndUpdate;

First, check whether the Item already exists. If not add Item, otherwise update.

Thanks for the code snippet!