Saving a Page Before Some Action on a Creatio Freedom UI Page

With Freedom UI pages, all client code executes as a request. There can be one, or multiple handlers of a request, but essentially, to do anything, you need a request to be executed for it to happen. This is the case saving the page as well. I’ve shown before how to handle (or respond to) the save request. In this article I will show how to initiate, or execute, the save request.

A handler on a Freedom UI page has a $context. This $context gives you access to things on the page such as attributes or other things. One of the things that is provided in the $context is a useful helper function to execute a request for the page (in 8.0.10 and above). This function simplifies the execution of a request (instead of using the HandlerChainService). Let’s say in this scenario we have a button on a page. If clicked, we want to first save the record, and then navigate to some other page. The code in our button’s click handler would look like this.

// create the save request
const saveRecordRequest = {
	type: "crt.SaveRecordRequest",
	preventCardClose: true,
	$context: request.$context
};
					
// now execute the save request and check if it was successful
if ((await request.$context.executeRequest(saveRecordRequest))) {
	// save was successful, continue with something else here
}
else {
	// save was not successful (maybe due to required fields not being filled in)
}

The code above will first execute a save request to save the page. If it was successful we could then do some other action as needed.

Want content like this delivered to your inbox? Sign up for our newsletter!
ABOUT THE AUTHOR

Ryan Farley

Ryan Farley is the Director of Development for Customer FX and creator of slxdeveloper.com. He's been blogging regularly about SalesLogix, now Infor CRM, since 2001 and believes in sharing with the community. His new passion for CRM is Creatio, formerly bpm'online. He loves C#, Javascript, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

Submit a Comment

Your email address will not be published. Required fields are marked *