It's all about the answers!

Ask a question

Javascript Validator Check

Peterson dos Santos (3928) | asked Jan 23, 5:59 p.m.
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:

2 answers

permanent link
Ralph Schoon (63.2k33646) | answered Jan 24, 2:35 a.m.

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

permanent link
Davyd Norris (2.4k217) | answered Jan 24, 5:55 p.m.
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

  const WorkItemAttributes =;
  const Status =;

        const wiState = workItem.getValue(WorkItemAttributes.STATE);
        if (wiState === null) {
          return Status.OK_STATUS;

Your answer

Register or 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.