how to fetch current date by selecting one particular enumeration value?
hello team,
I created two attribute one is attribute type enumeration having name "task status" below are the task status list:
Un-Assigned (Deafult),
Work In Progress(WIP),
On-Hold,
Completed,
Abandoned,
Rework,
Rework Completed
and another attribute type is timestamp having name "actual start date". now the thing is that whenever user select Task status as "Work in progress(WIP)" then actual start date set by current date and time.
for this I create script using value-set but its not working
My script is:
dojo.provide("org.example.workitems.providers.Actualstartdatescript");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojo.string");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("org.example.workitems.providers.Actualstartdatescript", null, {
getValueSet: function(attributeId, workItem, configuration) {
var actual_sd=workItem.getValue("actusl");
var TaskStatus=workItem.getValue("task_s");
if(task_s=="Work In Progress(WIP)")
{
return actual_sd.Date.now();
}
else
{
return "";
}
return actual_sd;
}
});
})();
I think this code is wrong please correct me.
and also I went through many of the solution but I am confused about how to get one particular value or selected value from enumeration and then assign that to actual start date by script.
I referred below link:
thanks in advance
sayli
4 answers
From the referenced question, read https://jazz.net/wiki/bin/view/Main/AttributeCustomization and/or https://jazz.net/library/article/1093 Lab 5.
Also please read How should I ask a question in the Forum if I want to receive useful answers?
From what you write
1. Value set is not what you want. Read https://jazz.net/wiki/bin/view/Main/AttributeCustomization again, you probably want a calculated value for the date.
2. Reading the enumeration is done by workItem.getValue(attributeID) or workItem.getLabel(attributeID). See https://jazz.net/wiki/bin/view/Main/AttributeCustomization. getValue() returns the ID of the enumeration iteral e.g. "literal1" and getLabel() the display value e.g. "High".
Comments
as per your answer I already mention that I went through sites that u provided but I didn't get to know how to get one particular value from enumeration through script. I write
var actual_sd=dojo.date.stamp.fromISOString(workItem.getValue("actual_SD"));
var TaskStatus=workItem.getValue("Status");
if(TaskStatus === "TaskStatus.WIP.2")
{
return actual_sd.Date.now();
}
but, whenever I select value from enumeration i.e "WIP", actual start date attribute doesn't show me current date and time. So is there mistake in my script about extracting value from enumeration?
From what you write
1. Value set is not what you want. Read https://jazz.net/wiki/bin/view/Main/AttributeCustomization again, you probably want a calculated value for the date.
Thanks Ralph for instant rply.
As you told I made script in calculated values but dependency of status and timestamp attribute is not working yet. whatever the changes made in script that cant triggered to Work item. I want output like when user save Work item creation date is automatically set in Work item attribute. just like that whenever user select status from status field then actual start date set by Work item.
I paste my code here. just check and please tell me where I am wrong
dojo.provide("org.example.new");
dojo.require("com.ibm.team.workitem.api.common.Status");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
var CalculatedOwner= dojo.declare("org.example.new", null, {
getValue: function(attributeId, workItem, configuration) {
var result=fromISOString(workItem.getValue("new3")); //this is my timestamp attribute
var a= Date.now();
if (workItem.getValue(WorkItemAttributes.STATE) == "WT.STATE.s2") { //WT is the id of workflow
return result=a;
}
}
});
})();