27
Views
8
Comments
Solved
How do I update a Date Time Attribute automatically?
Application Type
Traditional Web

Hey. Basically, I am developing an app to follow my tasks and their status(done, to do,  done, etc).

Everytime I create a new one, it saves the current date and time but I want that time and date to change every time I update my task. Can you help me?

If you want and need my data base, I can send you. Thanks.

SemTtulo.jpg

Rank: #66
Solution

Hi Gonçalo,


Before you call the CreateOrUpdateTask or UpdateTask CRUD action, make sure you assign the CurrDateTime() to the field Data, something like this:


Hope it helps.


Kind regards,
João

Rank: #23725

Hey! This really solved my problem!

I have one more question for you, if you can help me. Can I make somethnig like a record? Like (At 9 AM you changed this, At 10 AM that)

Rank: #66

Hi Gonçalo,


I'm glad I could help!

In order to keep track of every single change, you will have to have a table that saves the logs, something like {TaskLog} entity to have a record for every change in a task. This entity should have its own id + TaskId + the same attributes as Task + CreatedOn (when the record was changed) + CreatedBy (of type User Identifier, who changed the record).


And then you should implement the logic that whenever you create or update a Task, you create the corresponding TaskLog.


Regards,
João

Hi, 

You can update using Create_and_Update action or Update action with if condition. In your save action you have to assign date=CurrDateTime().

Hope This works.

Thanks,

Samiksha

Rank: #23725

Thank you! You helped me understanding more OutSystems and solved my problem!

Thank you!

Rank: #66
Solution

Hi Gonçalo,


Before you call the CreateOrUpdateTask or UpdateTask CRUD action, make sure you assign the CurrDateTime() to the field Data, something like this:


Hope it helps.


Kind regards,
João

Rank: #23725

Hey! This really solved my problem!

I have one more question for you, if you can help me. Can I make somethnig like a record? Like (At 9 AM you changed this, At 10 AM that)

Rank: #66

Hi Gonçalo,


I'm glad I could help!

In order to keep track of every single change, you will have to have a table that saves the logs, something like {TaskLog} entity to have a record for every change in a task. This entity should have its own id + TaskId + the same attributes as Task + CreatedOn (when the record was changed) + CreatedBy (of type User Identifier, who changed the record).


And then you should implement the logic that whenever you create or update a Task, you create the corresponding TaskLog.


Regards,
João

Hi Gonçalo,

As Marques suggested before calling update Task action you should assign Task.Date=CurrDateTime() I think it will be helpful for you.

If you still facing issue please share you oml.


Regards

Shashikant Shukla

Rank: #23725

Thank you! You helped me understanding more OutSystems and solved my problem!

Thank you!