Copied to clipboard

Flag this post as spam?

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


  • Kevon K. Hayes 255 posts 281 karma points
    Jan 21, 2012 @ 23:18
    Kevon K. Hayes
    0

    Creating a Document + Settings Properties in same code block

    UMB 4.5.2

    I'm attempting to set document properties immediately after creation but when doing so with the following code the properties aren't set.

    Document aDoc = Document.MakeNew(item.docFileName,erDT,author,parentNode.Id);
    aDoc.getProperty("electionYear").Value = umbraco.library.GetPreValueAsString(7); //UMB property is a dropdown
    aDoc.getProperty("electionResultDocumentType").Value = item.docType; //UMB property is a dropdown
    aDoc.Publish(author);
    umbraco.library.UpdateDocumentCache(aDoc.Id);
  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Jan 22, 2012 @ 04:08
    Jeroen Breuer
    0

    Looks like you're doing everything the same as in this wiki: http://our.umbraco.org/wiki/reference/api-cheatsheet/modifying-document-properties.

    Only difference is that in you're example you create it first and in the wiki it's already created. Could you try if it works for an item which already exists?

    Jeroen

  • Kevon K. Hayes 255 posts 281 karma points
    Jan 22, 2012 @ 04:41
    Kevon K. Hayes
    0

    CORRECTION [UMB 4.7.1]

    It works for Documents already created and for Documents created as the code example shows above, however only if the property is a textbox or label, but if the property is a Dropdown list as in my code example above, the property doesn't get set.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Jan 22, 2012 @ 13:47
    Jeroen Breuer
    0

    Maybe you're trying to store the wrong data? Have you looked at how it's stored in the umbraco.config file? Maybe you need to store it like that when you want to save it. 

    Jeroen

     

  • Kevon K. Hayes 255 posts 281 karma points
    Jan 22, 2012 @ 13:51
    Kevon K. Hayes
    0

    Please elaborate... If all the UMB controls are .NET controls maybe I can bind to it as shown here: our.umbraco.org/.../getprevalues, the only concern is getting the control ID name correct, as firebug shows:
    <select id="body_prop_electionYear" name="ctl00$body$prop_electionYear"> so I'll do a findcontrol() and try to bind to "body_prop_electionYear" and see what happens.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Jan 22, 2012 @ 13:57
    Jeroen Breuer
    0

    What if you try to save the text instead of the id which you databind to your dropdownlist. For example something like this:

    aDoc.getProperty("status").Value = "married";

    Jeroen

  • Kevon K. Hayes 255 posts 281 karma points
    Jan 22, 2012 @ 14:03
    Kevon K. Hayes
    0

    I'm not attempting to save the id at all... I was making a suggestion on trying to set the property via server control databinding since the regular way doesn't work.
    E.G:

    aDoc.getProperty("status").Value="married"; // WORKS FOR A UMB TEXTSTRING PROPERTY
    aDoc.getProperty("status").Value="married"; // WORKS FOR A UMB LABEL PROPERTY
    aDoc.getProperty("status").Value="married"; // DOES NOT WORK FOR A UMB DROPDOWN PROPERTY
Please Sign in or register to post replies

Write your reply to:

Draft