We would like to validate option values with a http request before the job executes. I created a ExecutionLifecyclePlugin with Java and hooked in the 'beforeJobStarts' and return a new ExecutionLifecycleStatus with "isSeccessful = false" if a certain value is set.
if (key.equals("test") && value.equals("asdf")) {
return new ExecutionLifecycleStatus() {
@Override
public boolean isSuccessful() {
return false;
}
@Override
public String getErrorMessage() {
return "value already exists";
}
};
}
But the behavior is not as expected, the job behavior as if the job run failes. The user can not change the field and send it again. The form should not submit and show the error message. I seems this plugin is not usefull for input validation.
Should we use a UI Plugin or is there a better option for validating the fields egains an external http function before execution?
To achieve your goal you need the JobLifeCycle plugin (not the ExecutionLifecycle Plugin), check the official documentation here. You need to use the beforeJobExecution
method.
Check the example here. And, the beforeJobExecution
method usage here.