How to query work item's customized attribute?
I have a customized attribute named 'extendStatus' and type is string. But the query by this attribute is broken. Here is the code segment.
WorkItemQueryModel model= WorkItemQueryModel.ROOT;
IItemQuery query= IItemQuery.FACTORY.newInstance(model);
IPredicate predicate = model.workItemType()._eq(query.newStringArg());
predicate = predicate._and(model.projectArea()._eq(projectArea));
predicate = predicate._and(model.stringExtensions().key()._eq('extendStatus'))._and(model.stringExtensions().value()._notEq('ARCHIVED'));
If i change the type to medium string, the query can work. My question is whether work item query model can support string extentions. If not, why stringextension exists in the model... Thanks in advance.
WorkItemQueryModel model= WorkItemQueryModel.ROOT;
IItemQuery query= IItemQuery.FACTORY.newInstance(model);
IPredicate predicate = model.workItemType()._eq(query.newStringArg());
predicate = predicate._and(model.projectArea()._eq(projectArea));
predicate = predicate._and(model.stringExtensions().key()._eq('extendStatus'))._and(model.stringExtensions().value()._notEq('ARCHIVED'));
If i change the type to medium string, the query can work. My question is whether work item query model can support string extentions. If not, why stringextension exists in the model... Thanks in advance.
One answer
I have a customized attribute named 'extendStatus' and type is string. But the query by this attribute is broken. Here is the code segment.
WorkItemQueryModel model= WorkItemQueryModel.ROOT;
IItemQuery query= IItemQuery.FACTORY.newInstance(model);
IPredicate predicate = model.workItemType()._eq(query.newStringArg());
predicate = predicate._and(model.projectArea()._eq(projectArea));
predicate = predicate._and(model.stringExtensions().key()._eq('extendStatus'))._and(model.stringExtensions().value()._notEq('ARCHIVED'));
If i change the type to medium string, the query can work. My question is whether work item query model can support string extentions. If not, why stringextension exists in the model... Thanks in advance.
You have most likely defined a custom attribute of type 'string'. In the query model, this corresponds to largeStringExtensions() and is not queryable. The mapping from custom attribute type to state extensions is as follows:
'string' -> largeStringExtensions (not queryable)
'mediumString' -> mediumStringExtensions()
'smallString' -> stringExtensions()
If you need a large string field, this is still searchable via full-text query.
HTH,
Patrick
Jazz Work Item Team