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

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

 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.

0 votes


Accepted answer

Permanent link

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

0 votes

Comments

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.

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"))

do you have the require on WorkItemAttributes ?

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

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.

 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);

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 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,939

Question asked: Nov 07 '17, 7:47 a.m.

Question was seen: 2,432 times

Last updated: Nov 08 '17, 2:36 a.m.

Confirmation Cancel Confirm