How to set ExportFieldCaption dynamically?

Is there any way to add server event listener for export?

In this case, I must manage all forms separately to decide whether to export captions or not. Therefore, I have defined a flag, and I want to export the caption versus the field name for all forms when the flag is set to true.

You may simply use Page_Load server event, for example, in List Page:

// export field caption
$this->YourFieldName->ExportFieldCaption = true; // adjust YourFieldName to your actual field name
// disable export field caption
$this->AnotherFieldName->ExportFieldCaption = false; // adjust AnotherFieldName to your actual field name

This way I have to write this for every form and every field. I want to control it centrally through the AddListener , Event Listeners with this command:

setFieldProperties("ExportFieldCaption",0);

If you want to change on table basis, then you may simply use Page_Load server event, for example, that belongs to the List Page:

Config("EXPORT_FIELD_CAPTION", true);

It depends on under what conditions that you need to change the setting. If you can determine independent of pages or users, you may simply set Config("EXPORT_FIELD_CAPTION") globally (for all tables/fields) in Global Code.

I want to configure it dynamically as a whole, rather than handling each form individually.