Javascript Validator Check
Hi Friends,
I would like to know if is there a way to check if a work item is new using javascript validators
I really appreciate any help:
|
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; } Peterson dos Santos selected this answer as the correct answer
|
One other answer
Ralph Schoon (63.6k●3●36●46)
| answered Jan 24, 2:35 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER 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/
|
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.