How to ge the field set values of Archetype datatype using Partial views Umbraco? - umbraco7

I am getting "Object reference not set to an instance of an object" exception when using the following code in Partial views section but same code working fine in Templates. Didn't understand why ?

That's a really general question. If you follow the Archetype documentation you won't have a problem getting the values.
Two things: "Not set to an instance of an object" means that you literally have asked something that doesn't exist. I've came across this error so many times and every time was the fact that my path
(e.g. your Model.Content in this case) is wrong. Maybe your editor is in another node or a parent or a descendant etc etc.
Second is: don't let razor 'guess' the type of value you need. Instead of
Model.Content.GetPropertyValue("example")
Try either: Model.Content.GetPropertyValue<string>("example")
Or: Model.Content.GetPropertyValue<int>("example")
That way, you won't be making mistakes when for example you ask for an int, but razor 'guesses' by itself you're asking for a string. Even if your path is correct, that might mess your code up.
However, first check your path. "Not set to an instance of an object" usually means that you're asking for something that's not there. Different path needed most probably.

Related

Object name becoming lowercase

I have some code which has worked in multiple installations for about a year. Today im doing a small change to a control and then another control seems to have developed an issue. When at runtime im getting a 91 error object variable or with block variable not set.
I therefore looked at the problem line which is: -
If Screen.ActiveForm.name = "frmFoutmelding" Then Exit Sub
so I noticed the name was lowercase. if i delete .name and rehit the "dot" then it shows me i can use .Name but as soon as i move from this line it drops back to .name
I've checked for instances of name and it appears everywhere in the code in different modules but i cant find if i have accidentally defined this lowercase name anywhere?
Googling doesn't seem to show much but i feel Im googling the wrong terms
chaps - thanks for your suggestions - this was the first instance of the lowercase name and searching as Jim suggested didn't reveal anything I'm afraid. What I did discover was that this was suddenly being run before any forms had actually been displayed and so the count was 0. I therefore, did an on error to check the form count and exit the sub if it =0 then if not to carry on with the line I thought I was having issues with.
It's likely that you did create a new variable or property called (lower case) name, or that some included reference did the same. It's possible to use reserved words as variable names in some cases, but it requires taking specific steps.
I would first search your code for instances of name As to see if you created a variable (this assumes you use Option Explicit, which is a must IMO). Then search for Property*name with * as a wildcard.
If those fail you could try unchecking references or components to see if any of them define name. If none of that finds anything, please post back here.
Jim Mack covers a lot of the potential issues. I think another is if you typed a lower case '.name' in association with Activeform at some point earlier in the same code module - the VB6 IDE checks in the current module and uses that to define what case to use. Look further up the same code module (sub or function).
Ultimately, check what changes you made by comparing the old source to the new in a file comparison tool like windiff - you do have backups, right?

Visual stuio template parameters not returning values?

I'm trying to get these parameters while creating a visual studio template but it doesn't return a value, it just stays like this:
string rootnamespace = $rootnamespace$; // this is the output, it just stays as it was declared
string SpecificSolutionName = $SpecificSolutionName$; // this is the output, it just stays as it was declared
According to msdn - Template Parameters:
SpecificSolutionName:
The name of the solution. When "create solution directory" is checked, SpecificSolutionName has the solution name. When "create solution directory" is not checked, SpecificSolutionName is blank.
And I made sure that the "create solution directory" is checked, but still it doesn't give any value.
How can I get these values. please... ?
I also found $SpecificSolutionName$ to be broken. As a work around it turns out the directory of the solution is usually the same as the name of the solution and thus:
If your solution template has only 1 project: the solution and project names are identical and thus you can simply use $projectname$ in lieu of the broken $SpecificSolutionName$.
If your solution template has multiple projects (aka ProjectCollection): add the attribute CopyParameters="true" to the desired ProjectTemplateLink element and use $ext_projectname$ in lieu of the broken $SpecificSolutionName$.
I think the documentation is not enough clear when it comes to multiproject templates. Putting the wizard declaration in the vstemplate of your multiproject definition, and on the project/s that you desired to use to, makes the "broken" variable appears.
This is because, it launch the wizard for each time you declare it, so to speak, and it behaves differently depending on the context.
Pay attention: the variable $SpecificSolutionName$ only has value when executing the first time for the multiproject vstemplate declaration, and only executes RunStarted, ProjectFinishedGenerating and RunFinished methods. So, to use it in a global context you need to figure out some kind of mechanism to mantain the value between Wizard executions, as adding a new key in the replacementsDictionaryor something.
Hope this help.
I fixed this by adding this doctype declaration to the start of my .vstemplate.
<?xml version="1.0" encoding="utf-8"?>
The doctype declaration is not supplied by the template wizard, but is present in all the preinstalled templates. Good luck and thank you for your patience while I researched this question.
$SpecificSolutionName$ is always empty. How can I tell if the user is making a new solution directory or not?
Frustratingly, the docs are wrong in 2 ways.
There is no "SpecificSolutionName". It is "SpecifiedSolutionName".
If the user unticks "Create directory for solution", then $SpecifiedSolutionName$ is not blank as stated; it actually becomes the same as $projectname$. How you determine when this has or has not occurred and whether what you're reading is a unique solution folder's name or not, is another story.

Debugger: Search for a variable which is used

I have the following problem:
I want to avoid that one field of the copied row gets copied into the new row. (ME51n)
I thought that I could search somewhere in the debugger for this field name.
Example:
first row has the MATNR: 100-1-15
now i want to search in the debugger for the field MATNR. Is this possible?
(I know this example does not make sense, but my field is not used that often because it's an self-created field)
Or is there an user-exit especially for that?
Use watchpoints for that particular aim that you stated. In official documentation you can learn how to do it. The problem of finding suitable user-exit is not related to original question.

Is there any way to clear out the "Testers" field in Microsoft Test Manager (or in TFS)

Seems like once you set the Testers field on a Test Case in MTM, it will not allow you to clear it. You are only allowed to change it to a different value. Has anyone found a way to clear this field?
It is important to not get the "Assigned" Tester field confused with the Assigned To field. They are distinct fields on a Test Case work item. One reason why someone might want the Tester field to be blank is if a team all pitches in to help with testing during an iteration and leaving the assigned tester blank allows the team to know that no one has "picked up" this test to execute. The team member could then assign the test to his or herself and execute it.
The template pulls the Assigned Tester Values from a list using the 'AllowedValues' tag. Instead, simply change this to 'SuggestedValues'. That will allow for empty values - easy as that.
If you'd rather not allow free entry, you can also add a default value such as 'None' and use that rather than blank.
Unless you've customized your work item type, this field should never be blank after being saved. It defaults to the person who created the bug in all Microsoft supported process templates, and a value is required by default.
That being said, why would you want to change it to blank?
If you really, really want to be able to blank it out (which I don't think is a good idea at all), you'll need to customize your template. See the below guidance:
http://msdn.microsoft.com/en-us/library/ms243849(v=vs.110).aspx

Generalizing Cucumber/Capybara Tests

I wrote a feature to test the default configuration of my web app using Cucumber and Capybara. Part of the feature looked like this:
And the page has a photo labeled "Device"
And the page has a checkbox labeled "Device"
And I check "Device"
And I submit the form
Then the resulting page has no photo labeled "Device"
It worked great. I want users who have installed and configured the web app on their own servers to be able to run the test to help confirm that their configuration is correct. And "Device" is a string in the default config file that the user can change. It's an element in an array and they can add to or remove from the array when configuring their instance of the app.
Is this a sensible use of the tools or am I abusing Cucumber and/or Capybara? If it's sensible, how would I do it? If it's a bad idea, what tools might I use for this instead, if anything?
Here's how I got it to work. I'm just not sure this is the best way to do it.
For this to work, the feature would have to look more like this:
And the page has at least 3 photos, let us call the last one "third_photo"
In the corresponding step definition, I use an XPath to pull out the corresponding label string for the first photo and assign it to a Hash object stored in a class variable.
And /^I the page has at least (\d*) photos, let us call the last one "([^\"]*)"$/ do |n, name|
if ! defined?(#note)
#note = Hash.new;
end
#note[name] = find(:xpath, '//ol[#id="menu"]/li[' +n+ ']/a').text;
end
Subsequent step definitions can now access the value, whatever it was.
So, another feature might be:
Then I uncheck "third_item"
And the corresponding step definition might be:
Then /I uncheck "([^\"]*)"/ do |item|
uncheck(#note[item])
end
But I don't feel good about it. If nothing else, I imagine there might be a name collision with another instance variable defined outside the step definitions.
It feels like I'm either Doing It Wrong or else I'm Using The Wrong Tool. What is the right way to do this?
Don't know what you are fishing after, but it feels like your tests and implementation are quite tightly coupled. Maybe that's the feeling you are having, that it seems like you are describing your app in tests.
I don't have a good answer to your questions, merely because I don't "understand" it. I would however urge you to try to decouple your tests from your implementation and see if there's any abstraction there waiting to be found.
There's a blog post about using instance variables in step definitions at http://www.cloudspace.com/blog/2010/06/23/using-instance-variables-with-cucumber-steps/.
Commenters talk about the coupling this entails and at least one possible way around it.
In particular, davetron5000 says:
What we do is to not use instance variables at all, but instead
provide a has that shared state can go in. This hash is cleared after
each test run. Not ideal, but it's a bit cleaner than random instance
variables all over the place (and also ensures a reasonably clean
state before each test)

Resources