Component creation lead info not getting saved - jira

I was trying to create a project component from my plugin. Code is below,
com.atlassian.jira.bc.project.component.ProjectComponent component =ComponentAccessor.getProjectComponentManager().create(“Sample Name”,“Sample description”,
“My Username”, AssigneeTypes.PROJECT_DEFAULT,“projectId”);
The component is getting created under the project specified but lead is not assigned. All other fields are reflected as expected.
My jira version is v7.10.1
When I create from project centric view, I am able to create the component with the required info.
Why the lead is not assigned to the component?

If you want to assign the project lead to the component you may try this:
ComponentAccessor.getProjectComponentManager().create("Sample Name","Sample description",
"My Username", AssigneeTypes.PROJECT_LEAD,"projectId");
Please note that not all project will have the default assignee as the project lead so assigning AssigneeTypes.PROJECT_DEFAULT may assign nobody to that component. You can check this in Project administration > Users and roles > Default assignee.

Related

Adding new "tab" to a bug work item in TFS 2017

I am trying to add a new "tab" to bug item in TFS 2017. Looking at the "tabs" you see things like "Steps to Reproduce", System, etc.
I have found information on changing work item types but nothing about adding a new "tab" across the top where you see Steps to Repro, System, Test Cases, Tasks. The change I want to make may not be possible? Or it is possible I don't know the correct verbiage to use when asking google. The think I want to change may not be a tab control at all it maybe something else different.
Thanks
***************** Updated questions after posting *****************************
After playing around with Process Editor -> WIT -> Open WIT from server -> Bug
as suggested by Andy Li-MSFT I don't see a lot of control on the formatting on the tab. I was planning to add fields in a grid like pattern like a table as shown below. I am able to get the values in the drop down list for field1 and add the fields. However I have a couple follow up questions if you have time.
Setting either the control or column for the control to read-only the column will not render when adding a new bug. I have a little more control if I set AllowedValues and Frozen for the column however the value can still be changed. Is there a better way to set read-only?
There is not much control on the layout. I am OK adding a lot of fields but would like them to be displayed in a table like structure. Is there a way to control the look of the fields on the form?
Is there a way to add the fields in a grid? This would be ideal so I only have one header for each column.
The last-updated-by and last-updated-date. Is it possible to track on a row level who made a change? If not I would be OK just adding a last updated by and last updated date to the new tab. Row level updates would be nice.
<pre>
Field 1 Field 2 (Read-only) Field 3 Last Updated By Last updated Date
Status (completed, empty, N/A) "Some text here which describes something to do" "Optional comments" tfs user name date/time
Status (completed, empty, N/A) "Some text here which describes something to do" "Optional comments" tfs user name date/time
</pre>
You need to modify the WIT definition file (Bug work item type in your scenario).
You can try below ways to do that:
Export the WIT definition file with witadmin commands, add a new tab under <TabGroup> and add a new control for it, then save and import the file. See Import, export, and manage work item types for details.
e.g:
<Tab Label="Tab0501">
<Control FieldName="System.ChangedDate" Type="DateTimeControl" Label="Test0501:" LabelPosition="Left" />
</Tab>
You can also use the TFS Power Tools to export/import WIT definition files or directly modify the files from server:
Visual Studio 2015 : Microsoft Visual Studio Team Foundation Server
2015 Power Tools
Visual Studio 2017 : TFS Process Template Editor
Reference below screenshot to do that.
Another way is writing an extension to Extend the work item form, you can reference my answer in another thread to do that.

TFS template rule on Area Path

We are using TFS 2017 Update 3 on premise. I have the ability to edit the process template for our projects, and wish to make a change to the area path. I wish to implement a rule on the Area Path to prevent it from being left as the root project name when a new feature/story/bug/task is created. I've tried to use PROHIBITEDVALUES with the root path explicitly stated, but when I save the template I get the following error:
Microsoft Visual Studio
Work Item Type: Bug
TF26062: Rule '' is not supported for the field 'System.AreaPath'.
There were validation errors. Continuing to save may cause the file to become unloadable, do you want to continue?
Yes No
If I click Yes, I then get:
Microsoft Visual Studio
Failed to save the 'Bug' Work Item Type to the server.
TF26062: Rule '' is not supported for the field 'System.AreaPath'.
OK
So my question is, what rule can I apply to the Area Path field to prevent users from saving work items with the root/default area?
Based on my test all the existing rules are not available for the System.AreaPath filed. No built-in rules to validate the Area Path.
However you can follow below steps to change the default Area Path to prevent it from being left as the root project name when a new feature/story/bug/task is created.
Navigate to Settings --> Work --> Areas
Click the link: the default team's settings.
Area --> Default Area --> Change --> Select the specific area -->
Set
Besides, if you want to validate the Area Path, as a workaround you can create a new field to assist on that, you can refer to this article for details: Work Item Rules Workarounds: Validating Area Path

Tfs project creation results in error: TF400930: Field 'System.ExternalLinkCount' is defined multiple times

I have recently upgraded an on-premises Team Foundation Server from Tfs 2015 to Tfs2015.Update3 (14.102.25423.0)
The upgrade was completed and all other functionality seems to work as usual.
A day or so ago I attempted to create a new Tfs project (TFVC) and that resulted in an error.
When I look at the application tier log files, I see the following:
[10:31:30.153] Executing step: Create the Team Project.
[10:31:30.167] Executing step: 'Create the Team Project.' WorkItemTracking.CreateTeamProject (4 of 13)
[10:31:30.183] Getting process template.
[10:31:31.463] Refreshing server caches.
[10:31:31.463] Importing work item link types.
[10:31:32.180] Importing work item types
[10:31:33.727] Importing work item types
[10:31:34.413] [Error] TF400930: Field 'System.ExternalLinkCount' is defined multiple times with different field definitions. Correct the field definition and try again.
[10:31:34.507] Microsoft.TeamFoundation.WorkItemTracking.Server.LegacyValidationException: TF400930: Field 'System.ExternalLinkCount' is defined multiple times with different field definitions. Correct the field definition and try again.
[10:31:34.507] at Microsoft.TeamFoundation.WorkItemTracking.Server.ProvisioningService.InternalImportWorkItemTypesOrGlobalWorkflows(IVssRequestContext requestContext, Int32 projectId, String methodologyName, IEnumerable`1 typeElements, ProvisioningActionType actionType, InternalSchemaType schemaType, Boolean overwrite, ProvisioningImportEventsCallback importEventCallback)
We are unfortunately making use of a customized template (which is based on the Scrum template) and it is exactly this template that causes the error.
When creating a new Tfs project (TFVC) based on the standard Scrum or Agile templates it works fine.
I downloaded the customized scrum template in question and did a grep search on “System.ExternalLinkCount”.
When I look at the fields they do seem to be of the same type.
Any ideas or suggestion why it is acting up in this way?
You can just remove the field definition from these work items, it's a standard field which will be added to all your work item types automatically.

How does TFS's convertworkspaceitem work?

I'm trying to follow the instructions for deploying a database via TFS build listed here:
http://www.mytechfinds.com/articles/software-testing/6-test-automation/64-db-deployment-tfs
The instructions include notes about how to configure a ConvertWorkspaceItem element. I've followed the directions, but TFS remains unhappy with my setting for 'Result' and 'Workspace'. For now, I simply entered the text from the directions ('dbproj' and 'Workspace', respectively). TFS complains about my values:
Compiler error(s) encountered processing expression "dbproj". 'dbproj' is not declared. It may be inaccessible due to its production level.
I'm trying to find basic tutorial information on the ConvertWorkspaceItem element, but other than the MSDN reference page there isn't a lot of info. Does anyone know much about configuring this element?
You need to specify valid variable names for both of these properties. there should already be a variable declared in the workflow called workspace, You will need to declare a variable of type string that you wish to receive the result of this activity and specify it's name as the Result property. It looks like in your linked article the author must have already created a variable called dbproj. At the bottom of the workflow designer is a variables tab where you can define your own variables.

How to determine used process template in Team Foundation Server after creation of team project

I'm looking for a way to determine what process template was used for a team project after it has been created. I can now only guess by looking at the work item types. I could not find any option in Visual Studio to retrieve this information. I need to know what processs template was used for team projects not created by myself.
If you check your work item type:
Scrum = Product Backlog Item
Agile = User Story
CMMI = Requirement
For TFS 2010 & TFS 2012, you can follow below process to determine which process template a team project used:
Go to Team Explorer;
Open Documents folder;
Process Guidance;
Open ProcessGuidance.html, this will open specific Process Template documenation that your team project base on.
Refer to thread
There is no way to tell, in general.
If you create (or edit) a process template, you can put an identifier into a property then you will be able to track which projects have your template(s)
To do this:
Edit Classification\Classification.xml
add a node:
tasks/task/taskXml/properties/property
like this:
<property name="templateName" value="myTemplate_1.0.1" />
Once you have projects created with this template, in the object model you will be able to pull this info from a project:
TfsTeamProjectCollection c = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(myuri);
WorkItemStore wis = tpc.GetService();
ICommonStructureService ICss = tpc.GetService();
foreach (Project p in wis.Projects)
{
string ProjectName = string.Empty;
string ProjectState = String.Empty;
int templateId = 0;
ProjectProperty[] ProjectProperties = null;
ICss.GetProjectProperties(p.Uri.ToString(), out ProjectName, out ProjectState, out templateId, out ProjectProperties);
Console.WriteLine("Project: {0}\tTemplate: {1}", ProjectName, ProjectProperties.Where(n => n.Name == "templateName").FirstOrDefault().Value);
}
templateId is always -1 so dont think that will help you.
Also - If you have the rights to, I recommend adding this property into all the templates (even the default templates) in your collection, so that you will be able to track the templates of all future projects. Don't know why they didn't put it in the default templates. (if enough people complain maybe they will)
I found another workaround: in SharePoint Central Administration you can see in the Site Collection list a comment that described the process template that was used. I was actually looking for a way to programatically retrieve it via the TFS API, but could not find it.
Using witadmin, you can list the work item types in the project. The /collection parameter is the TPC url and the /p parameter is the project name. Here is an example (below). If you know the name of a work item type that is specific to a process template, then you know which process template is being used.
Output of command console from my test TFS:
D:\Program Files\Microsoft Team Foundation Server 2010\Tools>witadmin listwitd /collection:http://suluserver:8080/tfs/De
faultCollection /p:"First Team Project"
Bug
Shared Steps
Task
Test Case
User Story
Issue
Risk
User Scenario
Risk-Issue
For visual studio online, go to your collection profile page. You can see all the projects inside your collection including the process template information.
The URL format to your collection page should be:
https://[accountname].visualstudio.com/[collectionname]/_admin
This is definitely late but here's a couple different resources I found while searching:
If you have access to the TFS database: Determine Process Template SQL
Open source WinForms application: https://github.com/renevanosnabrugge/TFS-ProcessTemplateVersionCheck
I don't know a fail proof way to find this out.
I would recommend the following: There is a exe called witexport.exe that can export the xml of a work item. You can then look through the xml to see what kind of template was used. (ie if the conchango template is used you will see references to it.)
To run it fire up the VS Command line prompt (in the start menu). Here is an example run:
witexport /f "C:\Type.xml" /t "http:\MyServer:8080" /p MyProject /n "Sprint BackLog Item"

Resources