Set new date in EndDate/Calender

HiI get a new field in our calender called Internal status. If the field Internal status have status “1” and EndDate are passed i want to set field EndDate to todays date. I want the same effect you could see in ToDO there ToDos following you in your calender until you are done. Problem is that a get no change when a try to set a value in EndDate, i guess it depends in the field EndDateTime.

I use this code in a Agent:

FIELD UNI_Status:= UNI_Status;

FIELD EndDate:= EndDate;

FIELD EndDateTime:= EndDateTime;

tmpDate := @Date(@Now);

@If(UNI_Status=“1” & @Date(@Now)>@Date(EndDate);@SetField(“EndDate”;tmpDate);“”);

SELECT @All

Any suggestion?

Kind regards

Fredrik

Subject: Set new date in EndDate/Calender

On first glance, you may simply have a problem in your @if statement because of order (see Designer Help about operator order of precedence).

Try this instead

@If(UNI_Status=“1” & (@Date(@Now)>@Date(EndDate));@SetField(“EndDate”;tmpDate);“”);

If it works, then it’s because the @if was doing this …

@If((UNI_Status=“1” & @Date(@Now))>@Date(EndDate);@SetField(“EndDate”;tmpDate);“”);

Subject: RE: Set new date in EndDate/Calender

Thanx, but nothing happends. I guess that my problem is that field EndDate get the values from EndDateTime but a don´t now how i will replace it.

(EndDateTime) Value you see in document properties

2007-12-21 20:00:00 CET

(EndDate) Value you see in client

2007-12-21 fr

(EndDate) Value you see in document properties

2007-12-21 20:00:00 CET

Kind regards

Fredrik

Subject: RE: Set new date in EndDate/Calender

OK. Now I see where you are working. The formula for EndDate in the CalendarEntry form is @If(EndDate = “”; @If(@IsAvailable(EndDateTime);EndDateTime; @Today); EndDate).

So try this in your agent …

@If(UNI_Status=“1” & (@Date(@Now)>@Date(EndDateTime));@Do(@SetField(“EndDate”;tmpDate);@SetField(“EndDate”;tmpDate));“”);@Command([ViewRefreshFields])