It's all about the answers!

Ask a question

How to read the bulit-in attribute value using dojo script in rtc eclipse?


MOHANAKRISHNAN CHINNASAMY (133) | asked Nov 07 '17, 7:47 a.m.

 Hi


I am trying to read the built-in attribute value from a workitem (ex : status which is next to the summary attribute). The id of the status field is com.ibm.team.workitem.attribute.state which connected with workflow for the work item type.
I want to read the value of this attribute to do some validation using script based validation in attribute customization, based on the value I need to display error message. 
I tried in many way by reading using WorkItemAttributes.STATE as per some solution provided in jazz site, but no luck.
Can any one help with the right set of statements how to read the vale from my build-in field given above.

Accepted answer


permanent link
Dinesh Kumar B (4.1k413) | answered Nov 07 '17, 7:54 a.m.
JAZZ DEVELOPER

hi Mohanakrishnan,

have you looked at this already :
    https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Accessing_an_item_s_Status_attri

MOHANAKRISHNAN CHINNASAMY selected this answer as the correct answer

Comments
Ralph Schoon commented Nov 07 '17, 8:14 a.m. | edited Nov 07 '17, 8:15 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Other than in the question the Status attribute does not have the ID mentioned above com.ibm.team.workitem.attribute.state. The wrong ID com.ibm.team.workitem.attribute.state is caused by https://jazz.net/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/219100

If WorkItemAttributes.STATE does not work, the reason is usually an error e.g. not declaring
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
.

If the link provided by Dinesh is not enough see https://jazz.net/library/article/1093 Lab 5. The JavaScript is crap (I am no a JavaScript developer) but at least the examples work and are explained. There is an example looking at the state.


MOHANAKRISHNAN CHINNASAMY commented Nov 07 '17, 8:25 a.m.
Hi Dinesh,

Thanks for your answer. I already tried using that link. but not working. below is my script. Not sure where the mistake is. I am using - workItem.getValue("com.ibm.team.workitem.api.common.WorkItemAttributes.STATE") to get the STATUS of the work item where I am displaying validation error at bottom. But its not providing the status .

return new Status(Severity["ERROR"],workItem.getValue("com.ibm.team.workitem.api.common.WorkItemAttributes.STATE"))


Dinesh Kumar B commented Nov 07 '17, 10:00 a.m.
JAZZ DEVELOPER

do you have the require on WorkItemAttributes ?

dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");


Ralph Schoon commented Nov 07 '17, 10:17 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

The above is not a script. I would suggest doing a step by step following https://jazz.net/library/article/1093 . Providing insufficient parts of the code will only cost everybody time.


MOHANAKRISHNAN CHINNASAMY commented Nov 08 '17, 1:01 a.m.

 Thanks Dinesh and Ralph. I think the issue with declaration. Its working fine with below statements. 


var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;var workFlowState = workItem.getValue(WorkItemAttributes.STATE);
alert("WorkflowState: " + workFlowState);


Ralph Schoon commented Nov 08 '17, 2:36 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

You are not supposed to use alert in AttributeCustomization. Use console.log as shown in https://jazz.net/wiki/bin/view/Main/AttributeCustomization .

showing 5 of 6 show 1 more comments

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.