Javascript Validator Check

Accepted answer

If a work item is brand new - ie. unsaved, then the workitem's state will be null, otherwise it will be a string representing the ID of one of the states you've defined in your workflow.
The following code snippet will check whether the work item is brand new and exit the validator
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("com.ibm.team.workitem.api.common.Status");
...
const WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
const Status = com.ibm.team.workitem.api.common.Status;
const wiState = workItem.getValue(WorkItemAttributes.STATE);
if (wiState === null) {
return Status.OK_STATUS;
}
if (wiState === null) {
return Status.OK_STATUS;
}
One other answer

Validators can access the current workflow state of a work item using workItem.getValue(WorkItemAttributes.STATE)
Some more information about what you can do: https://rsjazz.wordpress.com/2022/11/25/ewm-attribute-customization-introduction/