It's all about the answers!

Ask a question

how to control order of calculated value scripts?


Lorena Almela (1811517) | asked Oct 16 '14, 12:34 p.m.

Hi,

we are using RTC 4.0.6 and we are using calculated value scripts to set a default owned by value per state, and then users can change it.

We need the script to run only once in each state. As inside the scripts we can't know if it was fired due to a state change, and we are not able to get previous status then we have created another script that will save the old state and the script that sets the owner previously checks if the status is different to the old status in order to set the owner.

It was working fine in the development environment, the script that sets the owner runs first and then the other one that saves the status. But when we copied the process configuration to the Production PA (inside the same server) looks like the order of the scripts is not the same, looks like it is saving the old status first and then when the script that sets the owner runs it detects that the status is the same so it does not set the owner.

I'm not able to find the logs in the server to verify the execution order or to see if any other error appears, where can I find the script log in a WAS based installation? I tried on the C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\logs directory, but the scripts are not logged there.

How can I force the order of the scripts? How are the scripts being run? Is there a way I can be sure the script that saves the status runs at the end after the other has ran?

Here are the scripts used:

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

(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;

dojo.declare("com.example.common.GetOldState", null, {

    getValue: function(attributeId, workItem, configuration) {

       console.log("GetOldState Begin " + attributeId);

       var oldState = workItem.getValue("oldStatus");
       var state = workItem.getValue(WorkItemAttributes.STATE);

       console.log("oldState:" + oldState);
       console.log("state:" + state);
      
       if ((state != null) && (state.length != 0) && (state != oldState)) {
         oldState = state;
         console.log("GetOldState Cambio - oldState:" + oldState);
       }
       console.log("GetOldState End - oldState:" + oldState);
       return oldState;
    }
});
})();

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

(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;

dojo.declare("com.example.common.GetOwnedBy", null, {

   getValue: function(attribute, workItem, configuration) {
     
 console.log("GetOwnedBy Begin");
       
        var state = workItem.getValue(WorkItemAttributes.STATE);
        var oldState = workItem.getValue("oldStatus");
        var type = workItem.getValue(WorkItemAttributes.TYPE);
        var ownedBy = workItem.getValue(WorkItemAttributes.OWNER);
        console.log("state is:" + state + " - type is:" + type + " - ownedBy is:" + ownedBy + " - oldState is:" + oldState);
       
      
 //if ((state != null) && (state.length != 0)) {
 if ((state != null) && (state.length != 0) && (state != oldState)) {
  if (type === "Pasaje_entre_ambientes") {   //Pasaje entre ambientes
   if (state === "Pasajes_Amb.state.s1") {  //Ingresado
    ownedBy = "_PbZlMDnyEeS3NcBEfV4dZg";  //Grupo G.Ambientes
   }
  } else if (type === "Fast_track") {   //FAST TRACK
   if (state === "Fast_Track.state.s15") { //En Solicitud de Información GD
    ownedBy = "_IGKDEEQQEeSrZeql5JYL8A";  //Grupo G.Demanda CV
   } else if (state === "Fast_Track.state.s12") { //Rechazado
    ownedBy = "_IGKDEEQQEeSrZeql5JYL8A";  //Grupo G.Demanda CV
   } else if (((state === "Fast_Track.state.s3") && (equipoReso == "Equiporesponsable.literal.l2")) || ((state === "Fast_Track.state.s5") && (equipoReso == "Equiporesponsable.literal.l2"))) { //En Análisis SWF y Equipo Resolutor es IBM o 'En Desarrollo SWF' y Equipo Resolutor no es IBM
    ownedBy = "_Agl9z0WuEeSrZeql5JYL8A";  //Grupo IBM
   } else if (state === "Fast_Track.state.s8") { //Requerimiento Entregado
    ownedBy = "_gWWQgEQQEeSrZeql5JYL8A";  //Grupo Testing CV
   } else if (state === "Fast_Track.state.s10") { //Aprobado UAT
    //ownedBy = "_ABmRwDqDEeS3NcBEfV4dZg";  //Grupo Transición CV
    ownedBy = "_PbZlMDnyEeS3NcBEfV4dZg";  //Grupo G.Ambientes
   } else if (state === "Fast_Track.state.s16") { //Aprobado Transicion
    ownedBy = "_PbZlMDnyEeS3NcBEfV4dZg";  //Grupo G.Ambientes
   }
  }
    

 }

 console.log("GetOwnedBy End - ownedBy:" + ownedBy);
        return ownedBy;
   },
  
   __isGroup: function(identifier) {
      var isGroup = false;
      if ((identifier == null) || (identifier === "") || (identifier === "_YNh4MOlsEdq4xpiOKg5hvA") || (identifier === "_PbZlMDnyEeS3NcBEfV4dZg") || (identifier === "_WxPXcEQQEeSrZeql5JYL8A") || (identifier === "_IGKDEEQQEeSrZeql5JYL8A") || (identifier === "_gWWQgEQQEeSrZeql5JYL8A") || (identifier === "_ABmRwDqDEeS3NcBEfV4dZg")) {
       isGroup = true;
      }
      return isGroup;
   },

   __sentinel: null

});

})();

Please Help!

Thanks and Regards,

4 answers



permanent link
Lorena Almela (1811517) | answered Oct 16 '14, 8:06 p.m.
Some updates, i was finally able to find the scripts logs in the server, they are in C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\temp\SRV-RTCFE\RTC\ccm_war\ccm.war\eclipse\workspace\.metadata\ .log

I created a new attribute zoldstate to run the script and looks like now it is running this script after the others, so looks like the order of creation of the attribute affects on the order the calculated value script is executed.


permanent link
N Z (3622127) | answered Oct 16 '14, 6:58 p.m.
 Clutching at straws here, but did you set the same dependencies on the attributes in both your environments?

Like you, we find the whole script environment to be a black box which defies logic and reason!

Comments
Lorena Almela commented Oct 16 '14, 8:02 p.m.

Hi NZ,
yes, I've set the same dependencies, in fact the process configuration was copied from development into production, so it has the exact same configuration and both PA are in same server.
Thanks and Regards,



permanent link
Lorena Almela (1811517) | answered Oct 16 '14, 1:19 p.m.
Hi Sam,
thanks for answering. In the attachments section they are in alphabetical order.
I've even tried renaming the attachment name and the class so that it appears at the end of the list, but it didn't make any difference.
Do you know where to find the logs in the server in a WAS installation?
Regards,

Comments
sam detweiler commented Oct 16 '14, 1:26 p.m.

I do not know where the log info is for scripts (or anything else) in Websphere.


permanent link
sam detweiler (12.5k6195201) | answered Oct 16 '14, 1:11 p.m.
I don't think you have any control.. but there 'might' be a possibility.

scripts are added as project attachments (see the links tab after you open the project config in eclipse)..

it is 'possible' that the scripts were added in a different order.

I do not know if you can adjust the order by removing then re-adding the scripts in the same order where they work

Comments
Lorena Almela commented Oct 16 '14, 1:19 p.m.

Hi Sam,
thanks for answering. In the attachments section they are in alphabetical order.
I've even tried renaming the attachment name and the class so that it appears at the end of the list, but it didn't make any difference.
Do you know where to find the logs in the server in a WAS installation?
Regards,

Your answer


Register or 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.