how to get value of custom attribute of type workitem using javascript
I have scenario where I need to check value of custom attribute of type "workitem" in javascript. when I executed this script(added script based condition) every time I am getting null value . My code is,
var workitemAttribute=workItem.getValue(CustomAttributeID);
console.log("Value of Attribute = " + workitemAttribute); /// Output always shows null (LOG: Value of Attribute=null)
Can anybody help me out showing how to get value of custom attribute of type workitem?
var workitemAttribute=workItem.getValue(CustomAttributeID);
console.log("Value of Attribute = " + workitemAttribute); /// Output always shows null (LOG: Value of Attribute=null)
Can anybody help me out showing how to get value of custom attribute of type workitem?
Accepted answer
4 other answers
Ahh...problem with my fast reading habbit and I assumed you are probably writing a script based calculated value.
Check the Attribute Customization page and there are examples as well as descriptions for all script based attribute customization options.
Check the Attribute Customization page and there are examples as well as descriptions for all script based attribute customization options.
Hi Nilesh, did you ever get this working? I am facing the same problem...
Comments
Ralph, I am familiar with script based calculations - I have written a lot of them.
I need to get the value of a custom attribute of type Work Item
The following code returns NULL (doc.initiative is a Work Item attribute)
var initiative = workItem.getValue("doc.initiative");
I have looked at the webpage that you have referenced and can't find an example with an attribute type of Work Item.
Comments
I used the following script - calculated value:
The values where correct/contained something, when saving.
// custom-work-item-calc.js
/*******************************************************************************
* Licensed Materials - Property of IBM
* (c) Copyright IBM Corporation 2011. All Rights Reserved.
*
* Note to U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule
* Contract with IBM Corp.
*******************************************************************************/
dojo.provide("com.example.Calc_WI");
(function() {
dojo.declare("com.example.Calc_WI", null, {
getValue: function(attribute, workItem, configuration) {
var value = "-";
var label = "-";
var exception = "none";
try{
value = workItem.getValue("custom.workitem");
label = workItem.getLabel("custom.workitem");
} catch (e) {
exception = "Exception reading the attribute value: " + e;
}
return "Item:" + "\nValue: " + value + "\nLabel: " + label + "\nException: " + exception;
}
});
})();
The value went into the descriptions. The values were null when selecting the work item for the attribute.
The values where correct/contained something, when saving.
Comments
Indradri Basu
May 17 '13, 3:17 a.m.Nilesh Patil
May 17 '13, 3:46 a.m.