Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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:
Regards

0 votes


Accepted answer

Permanent link
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

0 votes


One other answer

Permanent link

 Validators can access the current workflow state of a work item using workItem.getValue(WorkItemAttributes.STATE)




0 votes

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,943
× 7,501
× 1,331

Question asked: Jan 23 '24, 5:59 p.m.

Question was seen: 842 times

Last updated: Jan 24 '24, 5:55 p.m.

Related questions
Confirmation Cancel Confirm