I create work items through the TFS api.
var type = project.WorkItemTypes["Bug"];
var workItem = new WorkItem(type)
{
History = "Created by OneTrueError incident #" + dto.OneTrueErrorIncidentId,
Title = dto.Title,
Description = dto.StackTrace,
};
workItem.Fields["Activity"].Value = dto.Activity;
workItem.Fields["Repro Steps"].Value = dto.StepsToReproduce;
workItem.Links.Add(new Hyperlink(someBaseUri + "/issue/" + dto.OneTrueErrorIncidentId));
workItem.Save();
At a later point I want to be able to fetch a specific work item by querying on a Hyperlink that I attached when creating the work item.
I can't figure out how to write that query. All examples I've found regarding links are for links to other work items or TFS resources. I have had no luck trying to modify those examples.
So how can I find a specific workitem using WIQL and a specific Hyperlink.Location?
Unfortunately, it's not able to directly use hyperlink url info in WIQL. You could only use Hyperlink Count field which returns the number of hyperlinks that are defined for the work item.
Reference Name=System.HyperLinkCount, Data type=Integer
As a workaround you may have to get a list of worktiems with links and go through all returned info to match the url that your attached when creating the work item. Then get the work item.
Related
I have a simple Examine search like so;
var results = Umbraco.Search(Request.QueryString["query"], true, "MySearcher");
foreach (var result in results)
{
<h2>#result.Name</h2>
<p>Content from 'contentgrid'?</p>
}
My question is, how do I get a snippet of text from the Grid? Propertyname is contentgrid.
Viewing the index, I can see there is a property named contentgrid containing the text, stripped from formatting etc.
Hi I wrote some code to allow you to do a more advanced search in umbraco.
This article gives you that code.
http://www.codeshare.co.uk/blog/how-to-search-by-document-type-and-property-in-umbraco/
I use it for the search on my website. The word mismatched only appears in the content grid for one article of my site. The below search url proves that it works.
http://www.codeshare.co.uk/search/?query=mismatched
Kind regards
Paul
I think there are two approaches you could take.
One is to add a custom field in the Examine index and then using the GatheringNodeData event, index the text that you want to display. That way you will be able to access it from the SearchResult object (#result.Fields["customFieldName"]). The GatheringNodeData event handler will have to parse the grid data to extract the text snippet you want and then add it to the Examine document (e.Fields["content"] = textSnippet).
The other approach would be to get the text snippet from the node when displaying the results.
var helper = new UmbracoHelper(UmbracoContext.Current);
foreach (var result in results)
{
var node = helper.TypedContent(result.Id);
var gridData = node.GetPropertyValue("contentgrid");
// some code for extracting the text snippet from the grid data
}
Note in both techniques, you need to figure out how to extract the text snippet you want from the grid data. You could use Skybrud.Umbraco.GridData or just parse the JSON yourself (using JSON.NET). I think the post #Harvey mentioned in a comment yesterday would be helpful for this (and more details on handling the GatheringNodeData event).
So I'm creating a SharePoint 2010 project in Visual Studio that contains a Sequential Workflow (Farm Solution only) item that is associated with a certain list so that when an item is added to the list the workflow starts.
My question is, say an item was added in the following format:
Name | Email
Dave | dave#dave.com
Is there a way, programatically, to store this data in variables? As is, without using any hardcoded indexes or anything, just programatically have it so that I can pull this data and store it in two C# variables (int iD, string emailAddress) and the workflow knows which list item kicked it off?
At the moment the way I'm doing it is:
using (SPWeb oWeb = SPContext.Current.Web) {
SPList oList = web["List Name"];
string name = list.Items[(oList.ItemCount - 1)]["Name"].ToString();
}
But I'd rather not use indexers as there's a chance that the index is off if another item is added rapidly and if the list is reordered then ... disaster.
Thanks in advance!
Solved it guys! Very stupid of me to overlook this, but here is the solution:
C# creates a workflowProperties variable for you of type SPWorkflowActivationProperties which contains all the methods and properties to get the data you need:
public SPWorkflowActivationProperties workflowProperties = new SPWorkflowActivationProperties(); // auto generated code.
Then to get the list item data or even list data all you do is:
SPList oList = workflowProperties.List; // get the list that contains the list item on which the workflow instance is running.
SPListItem oItem = workflowProperties.Item; // get the list item on which the workflow instance is running.
So to get my "Name" data I would've had to:
string name = workflowProperties.Item["Name"].ToString();
Hope this helps someone, although fortunately nobody is as stupid as me so you guys will probably figure it out yourself.
I have a RelatedLinks property in one of my pages that I need to get the links/PageIds out from in the code behind of my macro-user control.
I can get the property like this
var current = Node.GetCurrent();
Response.Write("Output: " + current.GetProperty("RelatedLinks").Value);
But the output is empty. When I debug I can see that the Value includes some list content (like tags and such) some somehow nothing is printed.
My question is how I can get the value from this property into something like a collection of hyperlink objects.
I'm new to Umbraco and I's possible that I'm missing something essential here. Getting the content of other property types (like the Content Picker) works fine.
Thanks!
You can use this simple solution in Umbraco 7.+
Model.Content.GetPropertyValue<Umbraco.Web.Models.RelatedLinks>("relatedArticles");
this simply convert data to static type that is easy to use.
What data type is your related links set to, assuming its a content picker where you are getting the id of the related page you could first create a node form your current page's id then try and get the value from that node e.g.
var current = Node.GetCurrent();
var currentPage = Model.NodeById(current.Id);
var relatedLinks = currentPage.RelatedLinks;
or
var relatedLinks = GetProperty("RelatedLinks").Value;
when you debug you should be able to see all the properties of currentpage and check your alias as well to make sure its right (generally aliases dont start with a capital by default).
Try this umbraco.NodeFactory.Node.GetCurrent().GetProperty("RelatedLinks")
Solved it like this:
Document doc = new Document(Node.GetCurrent().Id);
umbraco.cms.businesslogic.property.Property relatedLinks = doc.getProperty("RelatedLinks");
XmlNode relatedLinksAsXml = relatedLinks.ToXml(new XmlDocument());
However it says that the Document class is obsolete and wants me to use Umbraco.Core.Models.Content instead. But this is MVC right? I'm trying to use webforms. Tried using the Node class as described in this thread but the Property object I got returned was of the wrong type and couldn't be converted to XML.
I have added a new custom field in CMS_UserSettings table. The form control type is Multiple Choice. The data source for the control is set to a SQL Query. I would like to be able to populate the items in the control based on the selected user (Administration > Users). NOT the current user. Anyone know the syntax for this? Is it possible?
Here's my sample which pulls in the current users attribute. I need this to be the selected user.
SELECT ItemID, dealerNumber + ' - ' + dealerTitle
FROM cPort_DealerLocation
WHERE culliganGroupID = {%CurrentUser.culliganGroupID#%}
ORDER BY ItemID
You can access currently edited object through EditedObject macro - {%EditedObject.FieldName%}.
Edit:
It seems that a custom macro method is needed to do this for documents. I was able to do this by following code:
1) Create custom macro method (for how to do it see the documentation
MacroMethod method = new MacroMethod("MyEditedDoc", parameters => CMSContext.EditedDocument)
{
Type = typeof(TreeNode),
Comment = "Returns currently edited document.",
MinimumParameters = 0
};
MacroMethods.RegisterMethod(method);
2) Then in field editor of a document type you can use {%MyEditedDoc().DocumentName#%} and it gets resolved on the Form tab.
I've been given a task to make a dynamic drop down which takes it's data[image and value id] from table. I am wondering if any of you came across this scenario or if any one can help me out in this I need help in concept and coding. Definitely any help is appreciated.
I see the example in jquery here is the link:
http://www.marghoobsuleman.com/jquery-image-dropdown
something like this but data is coming from table.
If you use the plugin that you found in the link, then basically what you will want to do is create the dropdown dynamically based on the table content. Without having more details of how your table is structured I can't give you exact details, but something like this should get you close (I'm going to assume there is a drop-down element already on the page somewhere called "select", and your table is called "table" with the image in field 0, and the text in field 1) Note: This hasn't really been tested.
var options = "";
$("#table tr").each(function() {
var imagePath = $(this).find("td:eq(0) img").attr("src");
var title = $(this).find("td:eq(1)").text();
options += '<option value="'+title+'" title="'+imagePath+'">'+title+'</option>';
});
$("#select").html(options);