It's all about the answers!

Ask a question

How to fetch selected action to change status


Alejandro Gay (1168) | asked Aug 22 '14, 7:45 a.m.
I was reading other posts related and the attributes customization guide but still couldn't nail the problem here,
I want to trigger a java script to update the owner of a work item when I choose specific action from the drop down list to change from status A to status B.
I'm not talking here when the work item is saved, just when you choose one specific value on the drop list to trigger the script
So In the owner attribute definition I associated the calculated value with the the Java Script created, then I added a dependency on Status, but the script is not being called when I click on the status drop down list (to select the action I want).
The other problem I have is that fecthing the STATE get's be the value of the work item's status that is already saved not the Action that I'm choosing from the drop down list

my code is this

dojo.provide("org.example.SetCheckingOwner");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("org.example.SetCheckingOwner", null,
{ getValue: function(attributeId, workItem, configuration)
{ if (workItem.getValue(WorkItemAttributes.TYPE) === "com.ibm.team.workitem.workItemType.test_wi"
      && workItem.getValue(WorkItemAttributes.STATE) === "TestWI.state.s6")
{ return workItem.getValue("devticket.owner"); }
else
{ return workItem.getValue(WorkItemAttributes.OWNER); }}
}); })();


Any help on this?

3 answers



permanent link
Eric Jodet (6.3k5111120) | answered Aug 22 '14, 9:03 a.m.
JAZZ DEVELOPER
 Hello,
not sure what you want to implement.
Please provide a concrete example, with steps.
with the values  of owner, ticket owner, and what exactly is the behavior you want to implement.

I suspect you're trying to set the owner or ticket owner, when we switch to some new state.

Add some logging to your script, so you can not if it's called at all.

Thanks

permanent link
Eric Jodet (6.3k5111120) | answered Aug 22 '14, 9:03 a.m.
JAZZ DEVELOPER
 Somme logging sample:

/*******************************************************************************
* 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.ValueProvider");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); 

(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
    dojo.declare("com.example.ValueProvider", null, {

        getValue: function(attribute, workItem, configuration) {

var status = workItem.getValue(WorkItemAttributes.STATE);
        console.log("State: " + status);
        var owner = workItem.getValue(WorkItemAttributes.OWNER);
        console.log("Owner: " + owner);
        var dev_ticket = workItem.getValue("dev_ticket_owner");
        console.log("Ticket Owner: " + dev_ticket);
if (status === "com.ibm.team.workitem.defectWorkflow.state.s2") {
console.log("Ticket Owner");
  return dev_ticket;
  } 
else {
console.log("Owner");
return owner;
}

        }
    });
})();

permanent link
Alejandro Gay (1168) | answered Aug 22 '14, 1:38 p.m.
edited Aug 22 '14, 1:43 p.m.
when I select the Action Check-Out (when saved transitions the WI to status Checked-Out) I would like to assign the attribute OwnerI = devticket.owner value
so I have OwnerI defined with a calculated value as SetCheckingOwner script and Status as dependency
 

my code foe logging into the console is now
dojo.provide("org.example.SetCheckingOwner");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("org.example.SetCheckingOwner", null,
{ getValue: function(attributeId, workItem, configuration)
{
var WSTATUS = workItem.getValue(WorkItemAttributes.STATE);
var WTYPE   = workItem.getValue(WorkItemAttributes.TYPE);
console.log("SetCheckingOwner");
console.log("State: " + WSTATUS);
if (WTYPE   === "com.ibm.team.workitem.workItemType.test_wi" &&
    WSTATUS === "TestWI.state.s6")
   { return workItem.getValue("devticket.owner"); }
else
   { return workItem.getValue(WorkItemAttributes.OWNER);}
}
}); })();

so when I select any value of the action/status drop down the debugger indicates the following
 

so there is no indication that the script is executed, and I know that the script works because If I set OwnerI depending on any other attribute that I've already created like timespent2, I get the console messages in the debugger, but nothing when the dependency on done on the Status


Comments
Eric Jodet commented Aug 25 '14, 7:26 a.m.
JAZZ DEVELOPER

 Based on my testing,

script is triggered after you save the work item.

Please confirm.

Eric

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.