RALLY API: Could not set value for Tags: Cannot use type ObjectReference in attribute Tags - soap

I am trying to create a new story in Rally.
Using: https://rally1.rallydev.com/slm/webservice/1.40/RallyService
Below is the code
var parentStory = rallyService.query(Workspace, Projs["xxx"], true, true, "HierarchicalRequirement", query, "", true, 1, 20).Results[0] as HierarchicalRequirement;
var tag = new Tag[1];
tag[0] = new Tag()
{
Archived = true,
ArchivedSpecified = true,
CreationDate = DateTime.Now,
CreationDateSpecified = true,
Name = tagName,
};
var childStory = new HierarchicalRequirement
{
Name = feedback.FeedBackSubject,
Description = feedback.FeedBackDescription,
Parent = parentStory,
Owner = parentStory.Owner,
Tags = tag
};
return rallyService.create(childStory);
I am getting the following error: Could not set value for Tags: Cannot use type ObjectReference in attribute Tags
Thanks

I usually use the REST endpoints rather than SOAP but I would guess that you'll need to create your tag first before you reference it in the story you are creating. I think the error is due to the fact that the tag being passed in the array doesn't have a ref.

Related

How to query over a list of embedded documents with allow_inheritance

If I have the following schema:
class Post(EmbeddedDocument):
title = StringField(max_length=120, required=True)
meta = {'allow_inheritance': True}
class TextPost(Post):
content = StringField()
class MoviePost(Post):
author = ReferenceField(Authors)
class Record(Document):
posts = ListField(EmbeddedDocumentField(Post))
And I do the following query:
author = Author.objects.get_or_404(id = id)
records = Record.objects(posts__author = author)
records.count()
I get the following error:
AttributeError: 'author' object has no attribute 'get'
This seems to only happen with allow_inheritance when certain objects may or may not have the 'author' field. If the field exists on all objects, such as the 'title' field, the query works fine.
It seems that this is still an open issue in mongoengine that has yet to be addressed. One way around it is to use match. For example, the following does the trick:
records = Record.objects(posts__match = { 'author': author })

Select/Get html node from an element using D3

Let's say I have an html object called element that I create using bellow code:
var xmlString = "<div class="parent"><span class="child"></span></div>"
parser = new DOMParser()
var element = parser.parseFromString(xmlString, "text/xml");
// or simply using jquery
var string = "<div class="parent"><span class="child"></span></div>"
var element = $(string);
What I want to do is to select span.child from element using D3, not from the document. Using d3.select('span.child') will try to look for the <span class="child"></span> in the html document.
I checked the documentation and it says:
A selection is an array of elements pulled from the current document.
But I want to select not from the document but from the above element that I just created. Is there any way?
After a bit of debugging I found out that if element is a object, not string, then d3.select(element) will not look for the element in the document instead it will return the element itself.
for detailed info:
d3.select = function(node) {
var group = [ typeof node === "string" ? d3_select(node, d3_document) : node ];
group.parentNode = d3_documentElement;
return d3_selection([ group ]);
};

ActionLink for a Custom MapRoute with two URL Parameters

I have a custom MapRoute
context.MapRoute("participantByGender",
"Admin/Participants/{id}/{gender}",
new {
controller = "Admin",
action = "Participants",
id = UrlParameter.Optional,
gender = UrlParameter.Optional
}
and i need to have a link which specifies both the id and a default gender. I have this one, which works for choosing the id, but how would i alter this to include the id and the gender in the link?
#Html.ActionLink("Participants", "Participants", new { id = item.termId })
Simply use:
#Html.ActionLink("Participants", "Participants", new { id = item.termId,gender=model.property })

How to insert an item if not exists the one with the same name?

I'm inserting a batch of names:
myCollection.InsertBatch(value.Split(',').Where(o=> !string.IsNullOrEmpty(o)).Select( o => new Client { Name = o.Trim() }));
How to insert only the ones, that don't have the same Name?
p.s. Are MongoInsertOptions useful in this case?
Make unique index on "Name"
for example, in shell: db.MyCollection.ensureIndex({"Name":1}, {unique = true})
Add InsertOptions
var options = new MongoInsertOptions (myCollection) { CheckElementNames = true, Flags = InsertFlags.ContinueOnError, SafeMode = SafeMode.True};
var res = myCollection.InsertBatch(value.Split(',').Where(o => !string.IsNullOrEmpty(o)).Select(o => new Client { Name = o.Trim() }), options);

access to article by article name in ASP.NET MVC2

Greetings. How can I make access to my article or post by their name?
For example: Like at stackoverflow has access to this question by the name
access to article by article name in ASP.NET MVC2access-to-article-by-article-name-in-asp-net-mvc2
On StackOverflow the name part is completely ignored. It's the id that is important. This works: access to article by article name in ASP.NET MVC2 and links to this question. To generate links that contain the name in the URL you could define the following route:
routes.MapRoute(
"NameIdRoute",
"{controller}/{action}/{id}/{name}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional, name = UrlParameter.Optional },
new { id = #"\d+" }
);
And then:
<%: Html.ActionLink("some text", "action", new { id = Model.Id, name = Model.Name }) %>
Create a route that allows the name to be specified as part of the url. Note that it's probably not actually used in resolving the article as it might not be unique. The id is the bit of information that is actually used to find and display the correct article, but the name is part of the url for context.
routes.MapRoute(
"Question",
"{controller}/{id}/{name}",
new { controller = "questions", action = "show", id = UrlParameter.Optional, name = UrlParameter.Optional },
new { id = "[0-9]+" } // constraint to force id to be numeric
);
Now, when you use Html.ActionLink() and specify the name as a parameter, the route will match and put in the name as a component of the url instead of a query parameter.
<%= Html.ActionLink( "questions", new { id = Model.ID, name = Model.NameForUrl } ) %>
Note that if you have multiple routes that might match you may need to use RouteLink and specify the route by name. Also, order matters.