It's all about the answers!

Ask a question

How to create a script based on resolved state?


Bruno Cabral (714) | asked Oct 11 '18, 6:56 p.m.
Hello,

I am trying to create an attribute condition based "Resolved" set state.

Could please somebody help me?

* I don't want to use "required attributes for Type and State", because, I'll need to have two conditions on same script (sev1 and resolved status). For Sev1, script is working fine, but for resolved status, nothing is happening.

current script (not working):

dojo.provide("ibm.cio.required.sev1H");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function()
{   
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("ibm.cio.required.sev1H", null, 
{  
matches:  function(workItem, configuration)
{      
var state = workItem.getValue(WorkItemAttributes.STATE);
return (state === "11");
// status = resolved
}
});
})(); 

--------------------

element details:

<option value="com.ibm.team.workitem.defectWorkflow.state.s11">Resolved</option>

Thanks!

Comments
Don Yang commented Oct 12 '18, 12:51 a.m.
did you try with state === "com.ibm.team.workitem.defectWorkflow.state.s11"
( I did not try to run the script on my environment hence a quick check in comment)

Bruno Cabral commented Oct 12 '18, 7:07 a.m. | edited Oct 12 '18, 8:05 a.m.

Hi Don,


An update: Your State is working!!

It seems there was some issue on my server, and the updates made and saved on client were not being reflected as fast as normally is on UI/browser.

Thank you very much!

ps: I am not being able to mark your answer as the correct one, could you please convert your comment to answer (if possible) ? Or even let me know how can I mark your comment as the correct one.

->>Please ignore my previous comment below

Unfortunately, your state is not working either =(
I am still trying with other possible combinations, but with no success, so far.

If you have other suggestion, please let me know.


Ralph Schoon commented Oct 12 '18, 7:16 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

 https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Accessing_an_item_s_Status_attri explains states. If in doubt, debug or log the value of the attribute. 


Note, the state of the work item is the current state, you also get the workflow action in the condition. If the workflow action is not empty, the state of the item after the save will be the target state of the action.


Ralph Schoon commented Oct 12 '18, 7:17 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Bruno Cabral commented Oct 12 '18, 7:56 a.m.

Hi Ralph, thanks for your updates, two links you sent are very helpful!

I'll share my script as soon as I finish it in order to help others.

Thanks!

2 answers



permanent link
Ralph Schoon (61.4k33643) | answered Oct 12 '18, 2:32 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Oct 12 '18, 2:33 a.m.

 "Resolved" is a state group. I don't think state groups are available in the JavaScript attribute customization API. You have to code in all the states you consider resolved.


permanent link
Bruno Cabral (714) | answered Oct 12 '18, 8:20 a.m.
Hello,

When associating Don's comment (https://jazz.net/forum/users/dyang) with my already saved script, the attribute condition is working fine. Please check below the current code:

Condition: Ticket must be a Sev1 and State moving from any one to Resolved.

------------------------------------------------------------------------------------------------

dojo.provide("org.example.workitems.providers.FinishedCondition");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("org.example.workitems.providers.FinishedCondition", null, {

      matches: function(workItem, configuration) {
          var state= workItem.getValue(WorkItemAttributes.STATE);
var sev =  workItem.getValue(WorkItemAttributes.SEVERITY);
          console.log(typeof(state))
          return((sev === "severity.literal.l5") && (state === "com.ibm.team.workitem.defectWorkflow.state.s11"));
// sev1
// resolved
      }
});

})();
------------------------------------------------------------------------------------------------

Thanks and best regards!

Your answer


Register or to post your answer.