Rickard, have you looked at the SDK for visitor group criterias?
http://sdkbeta.episerver.com/SDK-html-Container/?path=/SdkDocuments/CMS/7/Knowledge%20Base/Developer%20Guide/Personalization/Personalization.htm&vppRoot=/SdkDocuments//CMS/7/Knowledge%20Base/Developer%20Guide/
Thanks Toni, yes indeed I checked that one, and some other (epi6) stuff. I as far as I understand, I have implemented the "must have", and I should not needd the dojo and/or controller stuff and more, correct?
Correct. I can't see any reasons why your code shouldn't work actually. Maybe there is more information if you log it?
This is known bug #91293, the fix should be available with the next platform and Edit UI updates.
For now the workaround could be creating custom rendering for your criterion model. Try to create MVC view BlessedCriterionModel.ascx and put the view in /Views/Shared/EditorTemplates folder on your site.
BlessedCriterionModel.ascx should render editors for your criterion model, something like this:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<EPiServer.Templates.Alloy.Business.VisitorGroups.BlessedCriterionModel>" %>
<%@ Assembly Name="EPiServer.CMS.Shell.UI" %>
<%@ Import Namespace="EPiServer.Personalization.VisitorGroups.Criteria" %>
<%@ Import Namespace="EPiServer.Personalization.VisitorGroups" %>
<div>
<div class="epi-critera-block">
<span class="epi-criteria-inlineblock">
<%= Html.LabelFor(model => model.Property1, new {@class = "episize200"}) %>
</span>
<span class="epi-criteria-inlineblock">
<%= Html.DojoEditorFor(model => model.Property1) %>
</span>
</div>
</div>
Oh a bug (darn), I suspected this from investigating the log (thanks Toni for this) And I successfully implemented your workaround. great!
Is this bug reintroduced in patch 2? Have tried both Rikards test group and one on my own and still get the "Failed to convert item"-error. Do you really need to create a MVC view to make it work?
I am also encountering this issue. I have tried adding the MVC view but this has not helped. Can anyone provide advice as to how to go about debugging / fixing this problem?
Thanks
I also get the "Failed to convert item" (testing with Ted Nyberg's CookieExists criterion http://tedgustaf.com/blog/2011/4/criterionbase-no-suitable-method-found-to-override/). I'm running CMS 7.1 with patch 3.
I don't know if this is any help for the rest of you but in my case, trying to use CookieExists, it was a case of me entering the value in the wrong textbox.
In the CookieExists criterion there is a parameter named "CookieName". Immediately below the label is a textbox in which I entered the cookie name. When I tried to save I got the message "Failed to convert item".
As I only expected to enter one value I never noticed that there was another textbox further to the right... This is actually the one I should have entered the value into. When doing so, and leaving the first textbox empty, I am able to save (and the visitor group criteria works).
I have no idea why the first textbox is there (or how to get rid of it) but I can live with that for now as everything works!
Update: It turns out the first textbox only appears in my development environment - on the production server everything is fine.
@Mikael,
I have a suggestion that the extra box is appearing because during your development you had another property in your Criterion model, and at one stage during your development you removed/changed property names. As the criterion affects the EPiServer tables it may be still linked to your criterion. ... Just a suggestion.
Meanwhile, I'm still looking for a solution to the "failed to convert".
I got the "Failed to convert" on Episerver CMS 7.1 MVC by using Dmytro Duk "hack", had to rewrite the aspx code to a cshtml file
@using EPiServer.Personalization.VisitorGroups
@model EPiServer.Templates.Alloy.Business.VisitorGroups.BlessedCriterionModell
<div class="epi-criteria-grouping">
<span class="epi-criteria-inlineblock">
@Html.DojoEditorFor(x => x.Property1)
</span>
</div>
This is however an ugly hack, cause you loose the ability to get the language data automatically. Please fix the bug?
I've created a simple visitor group and when I in Edit Visitor Group is trying to save it displays "Failed to convert item"