Requirement : If the Loadset(a work-item) Date is less than Today’s Date, change the status to "LockForLoad" automatically
Shuchi Arora (11●1●2)
| asked Sep 11 '15, 1:39 a.m.
edited Sep 11 '15, 3:03 a.m. by Ralph Schoon (63.4k●3●36●46) Hello, If someone could help me with the correct approach to enable this functionality in RTC, it would be really great. The requirement is to automatically change the status of the loadset - workItem as soon as the Loadset Date(Due-Date for the load) becomes less than today's date. I have written a script in "Calculated Value" area of "Attribute Customization", linked it with the "Status" Attribute, assigned "Due Date" as its dependency too. Initially I got compilation errors too which ensured the script gets hit, but now it looks like the script is not working for what it was written, not sure if I am missing on a Configuration or I need to write the script some where else, or I need to write a perl/shell script for the same..like we have cron jobs in Unix. Please advice a correct approach. The script I have written is:
dojo.provide("com.tvlprt.javascript.loadset_loadDateCrossed");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojo.date");
dojo.require("dojo.date.stamp");
(function() {
dojo.declare("com.tvlprt.javascript.loadset_loadDateCrossed", null, {
getValue: function(attribute, workItem, configuration) {
try {
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
var workItemType = (workItem.getValue(WorkItemAttributes.TYPE));
if( workItemType == "loadset" )
{
var Status = workItem.getValue(WorkItemAttributes.STATE);
//Figure out the LoadDate and then clean it up
var loadDate = workItem.getValue(WorkItemAttributes.DUE_DATE);
//Remove Dashes from the Load Date
var loadDateNoDashes = loadDate.replace(/-/g, "");
//Remove the last 14 characters from Load Date leaving us with the format: YYYYMMDD
var loadDateNoDashesNoTime = loadDateNoDashes.slice(0,-14);
//Figure out the current date or Today's Date
var currentDate = new Date();
var dd = currentDate.getDate();
var mm = currentDate.getMonth+1();
var yyyy = currentDate.getFullYear();
if(dd<10) {
dd='0'+dd
}
If(mm<10) {
mm='0' +mm
}
currentDate = yyyy+mm+dd;
//Compared the Loadset Date against Today's Date
If (loadDateNoDashesNoTime < currentDate)
{
Status = com.ibm.team.workitem.loadSetWorkflow.state.s2; //This is the "LockforLoad" ID.
return Status;
}
}
catch(err) {
var txt;
txt="There was an error on this page.\n\n";
txt+="Error description: " + err.message + "\n\n";
txt+="Click OK to continue.\n\n";
alert(txt);
}
}
});
})();
|
2 answers
Ralph Schoon (63.4k●3●36●46)
| answered Sep 11 '15, 3:13 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
When do attribute customization scripts run? They run if the work item is opened in an editor and if the dependent attribute changes.
Attribute customization is not a valid approach in this situation. You would have to create automation that
See https://rsjazz.wordpress.com/2012/10/29/using-work-item-queris-for-automation/ or https://rsjazz.wordpress.com/2012/11/19/using-expressions-for-automation/ . The blog has also code to change states of work items. If you have no experience with Java based RTC API coding, start here: https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/ and follow the links in the post how to set up your environment. Comments I should add, that a lot of the requests for automation of state changes for work items, especially if they are not related to changing states in other work items are mostly driven by some process requirement.
|
It looks to be the same question in this post.
https://jazz.net/forum/questions/206399/changing-a-work-item-status-based-on-the-result-of-a-date-comparison My advise? Don't do it. Comments Per Donald's response: Why are you recommending this NOT be done. Can you provide more of an explanation? Thanks.
Donald Nong
commented Sep 13 '15, 9:58 p.m.
Have you checked my response in the other post? The approach will cause lots of confusion and will do more harm than good.
Your comments and responses are still unclear to me. To answer your questions: 1) Yes, I want the status to change to 'LockforLoad' once the date condition is met, even if the status is 'New'. 2) I do not understand Question #2. Are you saying that once a work time is in the LockForLoad status (base on the date condition being met), it will always be in the LockforLoad status because of the chron job that runs.
Donald Nong
commented Sep 14 '15, 8:09 p.m.
Let me put it in another way.
|
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.