Scheduled task - Workaround to get ScheduledTaskConfigurationData editable in UI?
Unfortunately the existing field for the TaskData (ScheduledTaskConfigurationData) is not editable in the admin UI. Kentico support cannot tell me if and when this will become available.
Since we have been using this field since k4.1, we kinda miss this right now.
I wonder if there is some workaround to get it editable, so users/administators are able to change settings we have in this field, like notifyEmail or retryCount etc.
Environment
- Xperience by Kentico version: [30.1.1]
- .NET version: [9]
- Execution environment: [Private cloud (Azure)
Answers
It's unlikely to be available. Using scheduled tasks to execute a one off operation with custom data is not what they are designed for. Scheduled tasks should be used to run recurring, short-lived processes that don't require manual customization.
Instead, build a custom administration application with forms and buttons that marketers can use to run these background jobs.
You can see an example of this in the Kentico Community Portal source code.
You could also follow our guides and create a custom application to manage settings which your scheduled task could check each time it runs. The Kentico Community Portal also has an example of this.
The thing is Sean that we have always been using the data field for just being able to tweak some settings for that specific scheduled task. These are rarely changed, but could be, and right at there where you need it: at the scheduled task itself. These settings are not intended for marketeers in our case, but rather administrators.
One other example could be:
fullLogging: true
or:
logEmail: [email protected]
It don't know where that field since v4.1 was designed for, but for us it has always been very useful. Is it really hard to add the textbox to get it in line again with former Kentico versions?
What I'm saying is, although it might be useful for your use-case, we think that's not necessarily the right use-case for scheduled tasks so we probably won't expose it.
Scheduled tasks should be used to run recurring, short-lived processes that don't require manual customization.
My recommendation is to use a custom settings application (which you are likely already creating) and store the "settings" for tasks there.
While Sean is correct that you should look into the reason why you need to tweak it, there are cases where you want some settings that a scheduled task uses, and may want those controlled in the CMS (example, say you have a scheduled task that purges old comments, you may want the # of days configurable in case you want to change that).
I would use the KenticoDevTrev/XperienceCommunity.ChannelSettings: Module to easily create and manage Channel Specific Settings in Xperience by Kentico module. This allows you to easily add settings for the channel and retrieve them, with fall backs. Then you simply retrieve your settings module in your scheduled task.
To answer this question, you have to login first.