Rename the Title on load of the new record

Hello Community, 

 

Is it possible to bind the title of the form page from "New Record"  to a field value on load of a page in freedom UI.

 

Thanks

Gargeyi.G

Like 0

Like

1 comments

Hello,

You can change that by adding a handler like this - note this will change the value from "New record" when adding a new record for the 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.HeaderCaption = "Add a new something";
			}
 
			return result;
		}
	}
]/**SCHEMA_HANDLERS*/,

As far as binding it to some page value, you could use the same but first get a value from the page. Something like this:

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.HeaderCaption = "Add a new something";
			}
			else {
				// get a value from the page
				const someValue = request.$context.someAttributeOnThePage;
				request.$context.HeaderCaption = someValue;
			}
 
			return result;
		}
	}
]/**SCHEMA_HANDLERS*/,

Ryan

Show all comments