Are conditional targets in <transition> blocks supported in SCXML? - transitions

I want to implement this sort of a conditional transition in SCXML:
current_state = s01
if (Math.random() < 50) go to state s02
else go to state s03
Is this sort of conditional targets supported in SCXML ?
To put it into the SCXML language, is the equivalent of the following snippet possible ?
<transition event="event_1">
<if cond="import java.util.Random; Math.abs(new Random().nextInt(100)) gt 50">
<target="s02"/>
<else/>
<target="s03"/>
</if>
</transition>
Would appreciate any pointers to their doc. for this / alternative strategies to handle it.
Thanks.

Something like the following (untested) code will do what you want.
<scxml
datamodel="ecmascript"
xmlns="http://www.w3.org/2005/07/scxml"
version="1.0">
<state id="s01">
<transition event="event_1" target="s02" cond="Math.random() > .5"/>
<transition event="event_1" target="s03"/>
</state>
<state id="s02"/>
<state id="s03"/>
</scxml>

Related

TFS Assign Work Item By STATE ... with conditions

Our TFS is currently set up to assign a work item to our Tester (by capacity planning role) when the item goes from Active to Resolved state.
This is great, but it doesn't go far enough. When the Tester moves the item from Resolved to either Closed (tested and verified fixed) or Active (failed testing) I want to reassign the item back to whoever most recently transitioned it from Active to Resolved.
This way the person who fixed it is still associated with it when the defect is closed (get credit for your work) or if you didn't pass testing it gets reassigned back to the person that will be re-doing the work.
How can this be done?
Yes, your requirement can be achieved.
Automatically change AssignedTo field to a user when State field changes from Active to Resolved.
Assuming you have installed TFS Power Tool. You can modify the Transition from Active to Resolved (my example is from To Do to In Progress) by adding AssignedTo field and rules to this Transition:
The XML file should be like:
<Transition from="To Do" to="In Progress">
<ACTIONS>
<ACTION value="Microsoft.VSTS.Actions.StartWork" />
</ACTIONS>
<REASONS>
<DEFAULTREASON value="Work started" />
</REASONS>
<FIELDS>
<FIELD refname="System.AssignedTo">
<DEFAULT from="value" value="{Tester}" />
</FIELD>
</FIELDS>
</Transition>
In my example, when the State changes from To Do to In Progress, the AssignedTo field will change to Tester.
When the Tester changes State from Resolved to Active, the AssignedTo field will change back to whoever most recently change it
from Active to Resolved.
First, you need to customize a field to get ChangedBy value. In my example, I've customized a field named copy, the XML file looks like:
<FieldDefinition name="copy" refname="copy.copy" type="String">
<COPY from="field" field="System.ChangedBy" />
</FieldDefinition>
Then, similar to the item 1 above, you need to modify the Transition from Resolved to Active to (my example is from In Progress to To Do), the XML file looks like:
<Transition from="In Progress" to="To Do">
<ACTIONS>
<ACTION value="Microsoft.VSTS.Actions.StopWork" />
</ACTIONS>
<REASONS>
<DEFAULTREASON value="Work stopped" />
</REASONS>
<FIELDS>
<FIELD refname="System.AssignedTo">
<COPY from="field" field="copy.copy" />
</FIELD>
</FIELDS>
</Transition>
In my example, when the State changes from In Progress to To Do, the AssignedTo field will change to the user who change it most recently.
Might be there Solution for your question, but what I know is you don't need that just to see the person will be associate with it .
This is because if you see on right pane,when someone check-in the code for that work-item, or makes changes to that and saves the work-item ,automatically TFS shows in arrow with Steps continuously what have been done and by whom with date
and after failed testing. Developer who checked-in the code or try to solve that issue you can just select that developer name on dropdown on assign
I guess you were almost wanting similar the way i told but again if not forgive me.
Thanks,

Adding a state to a Work Item workflow in TFS 2013

My team recently migrated from TFS 2008 to TFS 2013. We are using the Agile template.
I noticed that for items that are Bugs, there isn't a way to specify that the item is "In Progress" or that "Work has started", it simply goes from the Active state to the Resolved state. I'm not sure what the logic is by not having an "In Progress" state between "Active" and "Resolved".
Anyways, I would like to add a new "In Progress" state but can't figure out how. Do any of you have any examples? I'm opening the Work Item Type Template in the Process Editor in Visual Studio. Do I need to manually edit the XML to add the state and try it until I get it right? Any examples?
Firstly, the following code shows you the workflow for Bug work item in Agile template. As the image shows, the states for Bug in Agile are Active, Resolved and Closed.
For your requirement to customize bug work item to change the workflow, you basically have two options: 1). Work with the work item type definition XML file as you mentioned above; 2). Work with Process Editor.
The details:
1). if you work with work item type definition XML file, you need to replace TRANSITIONS part with the followings (also assign appropriate actions & reasons you want):
<TRANSITIONS>
<TRANSITION from="" to="Active">
<REASONS>
<REASON value="Build Failure" />
<DEFAULTREASON value="New" />
</REASONS>
<FIELDS> . . . </FIELDS>
</TRANSITION>
<TRANSITION from="Active" to="In Progress">
<ACTIONS> . . . </ACTIONS>
<REASONS> . . . </REASONS>
</TRANSITION>
<TRANSITION from="In Progress" to="Resolved">
<ACTIONS> . . . </ACTIONS>
<REASONS> . . . </REASONS>
</TRANSITION>
<TRANSITION from="Resolved" to="In Progress">
<REASONS> . . . </REASONS>
</TRANSITION>
<TRANSITION from="Resolved" to="Closed">
<REASONS>
<DEFAULTREASON value="Verified" />
</REASONS>
<FIELDS> . . . </FIELDS>
</TRANSITION>
<TRANSITION from="Closed" to="Active">
<REASONS>
<REASON value="Reactivated" />
<DEFAULTREASON value="Regression" />
</REASONS>
<FIELDS> . . . </FIELDS>
</TRANSITION>
</TRANSITIONS>
2). If you want to work with Process Editor, you can add State on the Workflow tab. You can drag to add one State in WITDesigner pane from the Toolbox; and use Validate to check whether there is any error. See:
In one of the TFS 2013 Updates (I believe it is Update 4), we have updated the Agile template to include the New state to the Bug work item type to address this issue.
To add the state to your work item type, you can take two approaches:
Use witadmin or the power tools to manually add the New state
Download the latest Agile process template, and replace the Bug work item type on your TFS instance with the item from the downloaded template. You can get the latest copy of the Agile process template by creating an account on Visual Studio Online

Track Bugs as task on TFS 2012 project dashboard

I follow this article
to add bugs to task board on TFS. It works.
But the problem is that the initial state of created bug is "Active", I want it to be in "New" State, so I modify the workflow according to "Task" workflow. When I go into the backlog, it give me a error message
TF400917: The current configuration is not valid for this feature. This feature cannot be used until you correct the configuration.
I googled but nothing useful. Is there anybody could help on this?
You need to remove the none existing state "Active" from CommonProcessConfig, so first export it:
witadmin exportcommonprocessconfig /collection:"CollectionURL" /p:MyProject /f:"DirectoryPath/CommonConfiguration.xml"
Remove the Active entry:
<TaskWorkItems category="Microsoft.TaskCategory" pluralName="Tasks" singularName="Task">
<States>
<State value="New" type="Proposed" />
<State value="Active" type="InProgress" /> <-- this one needs to be removed, if there is no "Active" state in Bugs or Tasks
<State value="Resolved" type="InProgress" />
<State value="Closed" type="Complete" />
</States>
Import the updated config file:
witadmin importcommonprocessconfig /collection:"CollectionURL" /p:MyProject /f:"DirectoryPath/CommonConfiguration.xml"

TFS Workitems always leave 'Closed By' blank

We have a TFS workitem workflow where developers set workitems to be 'done'. It is largely our of the box with little custom configuration. This populates the 'Closed Date' but not 'Closed By'. The workflow continues as testers assign it to themselves and set the state to be 'Tested', but now I can no longer see on a report which developer closed the item.
How can I get a report of who did the work?
Given that you have a "Tested" state, it seems that the transitions have been customized. Ensure that all transitions to the "Closed" state have the correct rule on them to update the "Closed By" field. The Closed By definition on the transition should look something like this:
<STATE value="Closed">
<FIELDS>
....
<FIELD refname="Microsoft.VSTS.Common.ClosedBy">
<ALLOWEXISTINGVALUE />
<COPY from="currentuser" />
<VALIDUSER />
<REQUIRED />
</FIELD>
....
</FIELDS>
</STATE>
More information on customizing work item transitions can be found here and here.

TFS 2010 clear SystemAssignedTo in transition

We have introduced a "Code review" state for tasks, between "In progress" and "Done". When moving from "In progress" to "Code review" we would like to clear/unassign System.AssignedTo but I can't figure out how. Does anyone know where to put the logic in the WIT xml and what it should look like?
Thanks,
Mansos
Open your schema in an XML editor. Go down to the <TRANSITIONS> part and add
<TRANSITION from="In Progress" to="Code Review">
<FIELDS>
<FIELD name="Assigned To">
<EMPTY />
</FIELD>
<FIELDS>
</TRANSITION>
Make sure you don't have any <REQUIRED> for that field anywhere in the definition (there are a number of ways you can have that rule).
For reference, see http://msdn.microsoft.com/en-us/library/aa337653%28v=vs.80%29.aspx

Resources