It's all about the answers!

Ask a question

Suddenly problem in javascript (Work item customization)


Jia jang (428) | asked Apr 06 '17, 2:03 a.m.
edited Apr 07 '17, 1:56 p.m. by Ralph Schoon (57.1k23642)

hello all ,

I have a project area based on scrum template. 
I am working on work item customization . I created a custom workitem in that there are three custom attributes.
i.e. 1) actual start date
       2) Actual end date
       3) Total efforts
let me explain in details , 
1) actual start date ---------->current date/time is set when workitem state moved to "In progress" state.
2) actual end date ----------> current date/time is set when workitem state moved to "complete" state.
3) based on both these values (actual start date and end date) 'total efforts' are calculated immediately.

here is script for more details ...

dojo.provide("Actual3"); 
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); 
dojo.require("dojo.date.stamp"); 
dojo.require("dojo.date"); 

(function() { 
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes; 
var fromISOString = dojo.date.stamp.fromISOString;
dojo.declare("Actual3", null, { 

    getValue: function(attribute, workItem, configuration) { 

 var metoo;
    var currentDate= new Date();
var datum = currentDate.getDate();
var mjesec = currentDate.getMonth() + 1;
var godina = currentDate.getFullYear();
            var hours = currentDate.getHours();
            var minutes = currentDate.getMinutes();
            var seconds = currentDate.getSeconds();
 var startdate= dojo.date.stamp.fromISOString(workItem.getValue("asd"));
 
 var state = workItem.getValue(WorkItemAttributes.STATE);

 if (state.toString() == "com.ibm.team.workitem.taskWorkflow.state.s3")
 {
  var InSecond = (Date.now() - startdate.getTime()) / 3600000; 
   if(InSecond % 24 == 0)
   {
   if(InSecond / 24 == 1)
   {
    return "8 Hours";
   }
   if(InSecond / 24 == 2)
   {
    return "16 Hours";
   }
   if(InSecond / 24 == 3)
   {
    return "24 Hours";
   }
   if(InSecond / 24 == 4)
   {
    return "32 Hours";
   }
   if(InSecond / 24 == 5)
   {
    return "40 Hours";
   }
   if(InSecond / 24 == 6)
   {
    return "48 Hours";
   }
     }
 }
  else
  {
    var Me;
    var You;
    Me = InSecond % 24 ;
    You =  InSecond / 24 ;
    var Jio = parseInt(You.toString());
    You  = Jio * 8 ;
    return (You + Me).toString()+" Hours";
    
  }
 
 else
 { 
 }
 
  return "";
    } 
}); 
})(); 

****************
Please note this :- this script was working correctly from last 10/15 days , but now suddenly the output is not gonna display. I tried many times but all failed . 
****************
can anyone tell me , is there is any issues about javascript ? because code is correct but suddenly not responding.


Comments
Ralph Schoon commented Apr 06 '17, 2:41 a.m. | edited Apr 06 '17, 2:42 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Consider to look into the log files and/or debug the script. 


sayli Boralkar commented Apr 06 '17, 5:55 a.m. | edited Apr 07 '17, 1:54 p.m.

 I am also facing this same problem.

my script was working correctly from last 8 days , but now suddenly the output is not gonna display. I tried many times but all failed. So

Is their in support issue of JavaScript or else? 

I also go through debugging but while debugging whenever I open my script and start executing then control goes to bundle.js and vendor.js. file.  Debugging didn't look towards my script.  Is there any solution for this and is so then please tell me.

One answer



permanent link
Donald Nong (14.4k313) | answered Apr 06 '17, 6:38 a.m.

A conspiracy theory - double check that the state "com.ibm.team.workitem.taskWorkflow.state.s3" still exists.


Comments
1
Ralph Schoon commented Apr 06 '17, 10:07 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

+1 Don

Also see what https://jazz.net/wiki/bin/view/Main/AttributeCustomization says about states and how to identify them.

See https://jazz.net/library/article/1360 for how debugging them works.

PS: I have debugged calculated value scripts and that works if you follow what needs to ne done.


Jia jang commented Apr 10 '17, 1:25 a.m.

Hi ralph,

I have debugged the script its working but require to be triggered from some other attribute(i.e summary). It is not triggered by work item state itself.

Is there any license issue ? because our trial licenses are expired , and I am working on free ccm developer license. 




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

This is not a license problem. Attribute customization does not require a special license.

Note that the state does not change when you select the action the state would change after the save. Note that JavaScript does not have access to the action/state change. It can only access the value of the attribute. 


Jonas Studer commented Apr 10 '17, 4:00 a.m.

There's a possibility to access the workflows.

Check/Try this link:
Server: "localhost:7443/jazz"
Service: "/service/com.ibm.team.workitem.service.process.internal.rest.IWorkItemConfigRestService/workflows?projectAreaItemId="
ProjectareaItemId: "_ababababababab"

Make an XHR request to: SERVER+SERVICE+PAID
An you'll get the possbile workflow.

Your answer


Register or to post your answer.