November Happy Hour will be moved to Thursday December 5th.

VisitorGroupCriterion displays Failed to convert item

Vote:
 

I've created a simple visitor group and when I in Edit Visitor Group is trying to save it displays "Failed to convert item"

using System.Web;
using EPiServer.Personalization.VisitorGroups;

namespace EPiServer.Templates.Alloy.Business.VisitorGroups
{
	[VisitorGroupCriterion(DisplayName = "BlessedCriterion")]
	public class BlessedCriterion : CriterionBase<BlessedCriterionModel>
	{
		public override bool IsMatch(System.Security.Principal.IPrincipal principal, HttpContextBase httpContext)
		{
			return true;
		}
	}

	public class BlessedCriterionModel : CriterionModelBase
	{
		public override ICriterionModel Copy()
		{
			return ShallowCopy();
		}
	}
}

    

#63984
Dec 06, 2012 11:10
Vote:
 

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/

#63985
Dec 06, 2012 11:32
Vote:
 

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?

#63988
Dec 06, 2012 12:30
Vote:
 

Correct. I can't see any reasons why your code shouldn't work actually. Maybe there is more information if you log it?

#63989
Dec 06, 2012 12:34
Vote:
 

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>

    

#63994
Dec 06, 2012 13:59
Vote:
 

Oh a bug (darn), I suspected this from investigating the log (thanks Toni for this) And I successfully implemented your workaround. great! 

#63996
Dec 06, 2012 14:23
Vote:
 

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?

#71758
May 28, 2013 13:27
Vote:
 

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

#72414
Jun 17, 2013 2:18
Vote:
 

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.

#72519
Edited, Jun 19, 2013 13:19
Vote:
 

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.

#72523
Edited, Jun 19, 2013 14:55
Vote:
 

@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".

#72538
Jun 20, 2013 0:01
Vote:
 

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?

#73611
Edited, Jul 31, 2013 16:22
Vote:
 

I can see this bug has been marked as fixed however I am still getting the same error on a fully patched episerver 7 site when using the Role criterion from the codeplex criteria pack.

Is anyone still having issues with this on a fully patched site?

#76644
Oct 30, 2013 14:18
Vote:
 

Bump!


Any progress on this one? I'm experiencing the same thing in v7.5.

#80903
Feb 04, 2014 16:17
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.