How to set default value for a datetime field of tomorrow's date

Hello Community, 

 

How can we set the default value for a Datetime field to the tomorrow's date?

 

Thanks

Gargeyi.G

Like 0

Like

2 comments

I don't believe you can set a default for tomorrow's date in the object property defaults (unless you add it in the entity code). 

It's done pretty easily on the page if you want to add the code there, it would look like this (for a Freedom UI page):

handlers: /**SCHEMA_HANDLERS*/[
	{
		request: "crt.HandleViewModelInitRequest",
		handler: async (request, next) => {
			const result = await next?.handle(request);
 
			const cardState = await request.$context.CardState;
			if (cardState == "add" || cardState == "copy") {
				request.$context.TheDateFieldAttribute = Terrasoft.utils.date.addDays(new Date(), 1);
			}
 
			return result;
		}
	}
]/**SCHEMA_HANDLERS*/,

Ryan

Ryan Farley,

Thank you, it worked 

Show all comments