It's all about the answers!

Ask a question

Attribute customization - Calculated Values for enumeration list

Zachary K (19354339) | asked Aug 29 '12, 3:04 p.m.
edited Mar 18 '13, 1:37 p.m. by Ralph Schoon (63.3k33646)
I've created a calculated value in JavaScript to update an custom attribute based on the value of the "Filed Against" field.
I can get the id but not the label. Is there another api to get the label? I'm using RTC 3.0.1. 

 var filedAgainst = workItem.value(WorkItemAttributes.FILED_AGAINST); 

Or how can I convert the id to the display value?

Thanks in advance for your help

Accepted answer

permanent link
Ralph Schoon (63.3k33646) | answered Mar 18 '13, 1:37 p.m.
I agree to William. workItem.getLabel(WorkItemAttributes.FILED_AGAINST); should give you the label of the category. See Lab 5 for some guidance.

If the target attribute is an enumeration, you will however have to pass the literal ID to the enumeration and not the label.
Ralph Schoon selected this answer as the correct answer

3 other answers

permanent link
sam detweiler (12.5k6195201) | answered Aug 29 '12, 4:19 p.m.
the label is stored in the workflowInfo data item.

this code is in a plugin, but same deal

  fix this    -->          IAuditableCommon iac = p.getSaveOperationParameter().getAuditableCommon();
                WorkflowManager wfm = new WorkflowManager(iac);   
                    IWorkItemCommon workItemCommon = iac.getPeer(IWorkItemCommon.class);
                    // loop thru all the attributes in the project
                    // attributes are project wide, not workitem specific
                    for(IAttribute ia:workItemCommon.findAttributes(p.getOldProcessArea().getProjectArea(), monitor) )
                        // if this attribute is available on this workitem
                            System.out.println("processing for variable="+ia.getDisplayName()+" attrib type="+ia.getAttributeType());
                                // attempt to get the enumeration literal for this attribute
                                // will throw exception if not an enum
                                IEnumeration<ILiteral> enumeration = (IEnumeration<ILiteral>)workItemCommon.resolveEnumeration(ia, monitor);
                                    // get the literal specifically
                                    String[] iaval = ia.getValue(iac, workItem, monitor).toString().split(":");
                                    // if present
                                    if(iaval.length>1 && iaval[1]!=null)
                                        // loop thru the literal to value mappings                               
                                        for (ILiteral literal : enumeration.getEnumerationLiterals()) 
                                            // if this literal matches the attribute value
                                                // display the usable name
                                                System.out.println("attribute name="+ia.getIdentifier() +", type"+"="+ia.getAttributeType()+" literal="+literal.getIdentifier2().getStringIdentifier()+" literal name="+literal.getName());                                       
                            catch (Exception e)

permanent link
Zachary K (19354339) | answered Aug 29 '12, 5:44 p.m.
 Thank you but this is Java code and I need Javascript....
 I don't know how to access  the workflowInfo for instance.

sam detweiler commented Aug 29 '12, 9:56 p.m. | edited Aug 29 '12, 9:57 p.m.

I don't think you can get the values you need directly. the web model does a lot of preprocessing of the data before sending it to the browser.

permanent link
William Hunsicker (40610) | answered Mar 18 '13, 1:31 p.m.
var ReleaseDate = new String(workItem.getLabel(""));

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.