How to store the data of created by and created time. And Everytime user update it'll show the updated time and updated by. But the created by and created date will be constant all the time.
Hello Mosharof.
You need to do that in your logic.
If Id is null, assign CreatedBy, CreatedOn, UpdatedBy, UpdatedOn and do a Create.
If Id exists, assign only UpdatedBy, UpdatedOn and do an Update.
Hi Mosharof,
For this you need to create 4 columns in your entity createdBy, createdOn, updatedBy and updatedOn. IsMandatory will be false for these attributes.
Now you will pass the value of createdBy and createdOn while creates new record in create method of entity. Same way will pass value of updatedBy and updatedOn while updates any record in the updated method of entity.
In general you can take these values by GetUserId() and CurrDateTime().
regards
hello
I have done the updated by like this, it shows the updated time and updated by everytime. But for the created date and by it doesn't show. And in the DB I am allowed to save only the created by and created time. Not updated by and updated time.
Hi,
I am confused with the line "in the DB I am allowed to save only the created by and created time. Not updated by and updated time. "
You simply need to pass the values while creating or updating the records in create, update or createorupdate method. What issue you are facing in this.
It will be helpful if you can provide some screenshot of create and update method. So that will get idea what values you are passing.
Hi. Actually, the created by and created on these 2 fields need to be auto-populated from the user who logged in when he wants to create an employee. I added an server action inside there i used createOrUpdate then added assign.
For getting the values of these 2 fields you can user GetUserId() (will return loggedin user id) and CurrDateTime() ( will return current date time). But you have to pass these values while calling the Create or Update methods. Values will not be auto filled and for these values you need to call above 2 methods.
Hi thanks for your reply. Here the created date needs to be constant (The date the employee data is created), can not change it. So if I put the current date it changes every time when ever I do edit it.
No. You will pass currDateTime in createdOn only for create record. For update record you need to pass the value which already there and need to pass currDateTime in updatedOn.
Hello
You need to create a logic when EmployeeId is Nullidentifier, Then in that case you will save only CreatedDate and Created By, but when you are Updating It will go as UpdatedBy and UpdatedDate,
I am attaching a sample Oml, you can take reference from it.
Sample
I hope this will help
Thanks
Tousif Khan