We have moved to GitHub Issues
You are viewing the read-only archive of Umbraco's issue tracker. To create new issues, please head over to GitHub Issues.
Make sure to read the blog posts announcing the move for more information.
Created by Warren Buckley (Personal) 27 Aug 2013, 11:53:07 Updated by Shannon Deminick 18 Sep 2013, 23:58:02
Subtask of: U4-2891
Hello Shan, I have a 500 error with PostSave (http://localhost:59340/umbraco/UmbracoApi/Content/PostSave)
{ "Message":"Anerrorhasoccurred.", "ExceptionMessage":"Objectreferencenotsettoaninstanceofanobject.", "ExceptionType":"System.NullReferenceException", "StackTrace":"atUmbraco.Web.Editors.ContentPostValidateAttribute.OnActionExecuting(HttpActionContextactionContext)\r\natSystem.Web.Http.Filters.ActionFilterAttribute.System.Web.Http.Filters.IActionFilter.ExecuteActionFilterAsync(HttpActionContextactionContext,CancellationTokencancellationToken,Func`1continuation)" }
This is the JSON sent { "id":0, "properties":[ { "id":0, "alias":"siteName", "value":"Hello World" }, { "id":0, "alias":"siteDescription", "value":"Hello there" }, { "id":0, "alias":"bodyText", "value":"
Something here
" }, {I am trying to build a simple PropertyEditor that stores an integer of the selected Umbraco backoffice user from a dropdown.
My package manifest JSON is like so:
{
propertyEditors: [
{
id: "8a02c8fe-4d5d-4e6e-9525-e9a529928048",
name: "(CWS) User Picker",
editor: {
view: "/App_Plugins/UserPicker/user-picker.html",
valueType: 'int'
}
}
]
,
javascript: [
'/App_Plugins/UserPicker/userpicker.controller.js'
]
}
So I think the issue is with me trying to save the value as an int in Umbraco, as this was working fine when saving the value as a string. However when the dropdown was reloaded the selected item was not selected as the id was stored a string and the JSON for users is an int. Hence the need to store this as an int in Umbraco.
My view for user picker
<div class="row">
<select name="{{ model.alias }}" ng-model=" model.value" ng-options="user.id as user.name for user in users">
<option value="">Select User</option>
</select>
</div>
<hr/>
<h6>Debug JSON</h6>
{{ model | json }}
<h6>Users JSON</h6>
{{ users | json }}
<h6>Selected User</h6>
{{ model.value }}
And finally my controller for this angular.module("umbraco").controller("CWS.UserPickerController", function ($scope, $log, assetsService, userResource, notificationsService) {
//Start log message
$log.log("Start User Picker Controller");
//Try and getAll() users
userResource.getAll().then(function (userArray) {
//Log message - we got the users
$log.log("Get All Users Returned");
//Get the array of users back from getAll()
var users = userArray;
//Log the array
$log.log(users);
//Set the users variable into our scope
$scope.users = users;
});
//now we need to check if the value is null/undefined, if it is we need to set it to "" so that any value that is set
// to "" gets selected by default
if ($scope.model.value === null || $scope.model.value === undefined) {
$scope.model.value = "";
}
//Ending log message
$log.log("End User Picker Controller");
});
Cheers, Warren :)
1 Attachments
SO it was working with string ?
There's currently an issue with the content service caching when data types change. Have you tried restarting your app pool after the the data type has been saved again so it knows to save the data as int ?
Hello Shannon, I done a clean install from the latest nightly and tried again. I am now getting a new YSOD from PostSave
I am sending 0 as the value from the user picker property aka the Admin user in Umbraco.
{ "id":1051, "properties":[ { "id":10, "alias":"siteName", "value":"Simple website" }, { "id":11, "alias":"siteDescription", "value":"Off to a great start" }, { "id":12, "alias":"bodyText", "value":"\r\n
The Simple Starter Kit gives you a bare-bones website that\r\nintroduces you to a set of well-defined conventions for building an\r\nUmbraco website.
\r\n\r\nThe Simple website is very basic in form and provided without\r\nany design or functionality - unless you add a Skin, of course. By\r\ninstalling the Simple Starter Kit, you'll begin with a minimal site\r\nbuilt on best practices. You'll also enjoy the benefits of speaking\r\nthe same "language" as the rest of the Umbraco community by using\r\ncommon properties and naming conventions.
\r\n\r\nNow that you know what the Simple site is, it is time to get\r\nstarted using Umbraco.
\r\n" }, { "id":19, "alias":"user", "value":0 }], "name":"Simple website", "contentTypeAlias":"umbHomepage", "parentId":-1, "action":"publish", "releaseDate":null, "expireDate":null }
{
"Message":"An error has occurred.",
"ExceptionMessage":"The value Umbraco.Core.Models.Editors.ContentPropertyData cannot be converted to the type Integer",
"ExceptionType":"System.InvalidOperationException","StackTrace":" at Umbraco.Core.PropertyEditors.ValueEditor.FormatDataForPersistence(ContentPropertyData editorValue, Object currentValue) in f:\TeamCity\buildAgent\work\e1a0ddf7a1349eaf\src\Umbraco.Core\PropertyEditors\ValueEditor.cs:line 175\r\n at Umbraco.Web.Editors.ContentControllerBase.MapPropertyValues[TPersisted](ContentItemSave1 contentItem)\r\n at Umbraco.Web.Editors.ContentController.PostSave(ContentItemSave
1 contentItem)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.
Looking at that class that this YSOD is coming from I cannot see what the issue is as the code seems all OK. Think I will try and download the source and step through that class to see what the issue is.
https://github.com/umbraco/Umbraco-CMS/blob/7.0.0/src/Umbraco.Core/PropertyEditors/ValueEditor.cs
Here is a screenshot from TryConvertValueToCrlType.
As the screenshot shows. It cannot cast a Int64 to a Nullable Int32 hence the YSOD I am getting.
strange, now just trying to figure out why it is posting as int 64
I think Json.Net must format a json numeric as int 64. My numeric property editor is posting the value as a string which is then converted to an int, i guess to date I haven't tried just posting a json numerical value! I'll fix up.
I've made the change in this revision: 52700c0c18c8771e1200e3307d2ec5462c14476b
So if you can test with that change, that would be great. If it doesn't work, please re-open and let me know what happened.
OK would it be built into a nightly or do I need to download the source and build out a release zip from there?
If you are actively working with belle I would strongly recommend that you just work based on the repo since it changes heavily every day. Otherwise if the nighties are working you'll have to wait till it's out.
OK I will work with the repo instead then
Yes its saving the integer just fine now. Now I have an issue with the dropdown not selecting the correct item from the value saved in $scope.model.value
Priority: Normal
Type: Bug
State: Fixed
Assignee: Shannon Deminick
Difficulty: Normal
Category:
Backwards Compatible: True
Fix Submitted:
Affected versions: 7.0.0
Due in version: 7.0.0
Sprint:
Story Points:
Cycle: