Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Chad Rosenthal 272 posts 474 karma points
    Jan 23, 2016 @ 05:29
    Chad Rosenthal

    umbraco.decimal doesn't seem to work with setvalue in umbraco 7.4 beta 2

    Using Umbraco 7.4 Beta 2 which was installed and upgraded through nuget.

    I'm having an issue where I have an Umbraco.Decimal Proprerty Type attached to a document type.

    Here is the property type - enter image description here

    I'm creating a new node of content in an API, and it keeps throwing errors.

    IContent pieceOfContent = _contentService.CreateContent("name of node", parentNode, "contentType");
    pieceOfContent.SetValue("decimalProperty", .5);

    When I run this, it throws an error on the SetValue line.

    Object {Message: "An error has occurred.", ExceptionMessage: "The best overloaded method match for 'Umbraco.Core…Value(string, string)' has some invalid arguments", ExceptionType: "Microsoft.CSharp.RuntimeBinder.RuntimeBinderException", StackTrace: " at CallSite.Target(Closure , CallSite , Object …tpControllerDispatcher.

    If I run the same line above as:

    pieceOfContent.SetValue("decimalProperty", 1);

    It works.

    So I don't know if I'm doing something wrong, Or if there is a bug.

    Thanks, C

  • Nik 1200 posts 4996 karma points MVP 2x c-trib
    Jan 23, 2016 @ 09:34

    Hi Chad,

    I don't know if this will solve the issue but have you tried 0.5 instead of .5? It could be fact it starts with a . causing the issue?

  • Chad Rosenthal 272 posts 474 karma points
    Jan 24, 2016 @ 00:49
    Chad Rosenthal

    Ok. Tried, that. Still no go. If I send it as an integer or a string it works. Decimals don't work.

  • Chad Rosenthal 272 posts 474 karma points
    Jan 24, 2016 @ 01:14
    Chad Rosenthal

    So looking at the source, it ends up calling methods in the contentbase.cs file. I see ones for bool, datetime, httppostedfilebase, httppostedfilewrapper, int, long, and string.

    If I convert to a string, it works...but really...there should be a way to get a double or decimal without having to convert it first to a string.

  • Chad Rosenthal 272 posts 474 karma points
    Jan 24, 2016 @ 04:52
    Chad Rosenthal

    Made a pull request, but the workaround is to convert the decimal/double to a string.

Please Sign in or register to post replies

Write your reply to: