'How to export custom fields configuration into a config file in Liferay?

So, Liferay offers an option to export settings into a configuration file so that another Liferay instance can be easily and quickly configured with the settings from the first instance.

Liferay documentation specifies this:

System Settings provides an Export option that becomes available once you modify a configuration entry. Exporting is the recommended way to create .config files.

As I understand, what they are referring to when saying "System settings" is a location "Control Panel → Configuration → System Settings".

And this export option really is available there... But only there. But there are many other places under "Control panel → Configuration" where I can not find an Export option.

For example, "Control Panel → Configuration → Custom fields". My question here is, how do I create a config file for configuration in this location?

Our problem is that we added many custom fields into the "Custom fields" configuration section in our testing environment, and now we want to deploy a new version of the application in the production environment. Sure, we can create each field in the production manually and then do the deploy, but, can not we create a configuration file for "Custom fields" section? Today I have been tasked with exploring ways to reduce the deployment time, and if we need to create every custom field in the production environment manually, then this is the main reason why deployment time will be long (> 30 minutes).

We are using Liferay Community Edition Portal 7.0.4 GA5 (Wilberforce / Build 7004 / October 23, 2017) version of Liferay, in case it matters.



Solution 1:[1]

In places where you don't have the "export" option (which are the places within System- and Instance-Settings that you describe), there is nothing generic - so there are completely different ways to export certain options for various items.

The System- and Instance-Settings are the central place for anything that's configured through OSGi's configuration mechanism (and it will replace the old portal.properties method more and more, especially in versions younger than yours)

Custom Fields have an API (called "Expando" in the backend) and the Expando API is mirroring Table, Column and Value. You can use the Expando API to access all the values that you've configured, and also to create them. That might take longer than entering them manually (especially when you'll have to look for them) but might ease later deployments to yet another system.

The best way to handle this upfront is if you don't create Custom Fields manually at all, but always make sure that your application comes with all the custom fields that it requires (created through the API). This way, whenever you install the application, the custom fields will match the application's expectations. I understand that it's too late for this now.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Olaf Kock