Trying to get CurrDate() if an action is complete

I am trying to create an IF statement for when an my data returns a "Complete" it then assigns the date that item is marked complete and if the data returns anything else that is not "Complete" it returns no date. How would I go about doing this? 


I created a local variable "CompletedDate" and assign in my preparation, but I am having trouble creating the if in the expression editor.  




Hi,

In the assign node for CompletedDate, use

if(status = "Complete", CurrDate(), NullDate())

Status should be whatever has the item status that you want to check.

Regards,

Daniel

Daniël Kuhlmann wrote:

Hi,

In the assign node for CompletedDate, use

if(status = "Complete", CurrDate(), NullDate())

Status should be whatever has the item status that you want to check.

Regards,

Daniel

Thank you Daniel that works! Another question. So my null date is 1900/01/01. Is there a way to just have that as blank/empty if it returns a null value?



Correct in OutSystems NullDate is 1900/01/01.

If you need to return something empty as in empty string then the CompletedDate should be text, but I would only consider that as output to external system not how to do it internally in OutSystems.

If you need to show the value of CompletedDate of data type Date in an expression you can do in the expression:

If(CompletedDate = NullDate(), "", CompletedDate)

On an input widget for the date you can set the null value:

Daniël Kuhlmann wrote:

Correct in OutSystems NullDate is 1900/01/01.

If you need to return something empty as in empty string then the CompletedDate should be text, but I would only consider that as output to external system not how to do it internally in OutSystems.

If you need to show the value of CompletedDate of data type Date in an expression you can do in the expression:

If(CompletedDate = NullDate(), "", CompletedDate)

On an input widget for the date you can set the null value:

Okay so in the expression how would I have both IF statements if(status = "Complete", CurrDate(), NullDate()) and If(CompletedDate = NullDate(), "", CompletedDate)?


Yes, but the have both their own purpose: 

  •  if(status = "Complete", CurrDate(), NullDate())  to set the value of CompletedDate
  •  if(CompletedDate = NullDate(), "", CompletedDate) to show no date (if null) or the date in an expression.

Daniël Kuhlmann wrote:

Yes, but the have both their own purpose: 

  •  if(status = "Complete", CurrDate(), NullDate())  to set the value of CompletedDate
  •  if(CompletedDate = NullDate(), "", CompletedDate) to show no date (if null) or the date in an expression.

Okay so I have that working now, but only the first item on my list has an impact on completed date. Anything lower than the top item has no impact regardless of their status. 


Hi,

The problem is, now I see your screen shot, that you set the CompletedDate in a local variable (which will act on the first record in your aggregate. Therefor you see the value for CompletedDate to be the same for all remaining rows. 

What you should do is 

  1. extend the entity and add CompletedDate as an attribute of type date.
  2. Then in the action that changes the status to Complete then you should also set CompletedDate to CurrDate().
  3. Then change the table record  and show the CompletedDate attribute from the aggreate instead of the local variable.

Regards,

Daniel