Copied to clipboard

Flag this post as spam?

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


  • Jonas 123 posts 206 karma points
    Mar 12, 2015 @ 20:13
    Jonas
    0

    GetRecordsFromForm Umbraco Forms.

    I cant get GetRecordsFromForm to work. Are there any documentation out there ?

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Mar 12, 2015 @ 20:17
    Dennis Aaen
    0

    Hi Jonas,

    Yes you can find the documentation about Umbraco Forms here: https://our.umbraco.org/documentation/Products/UmbracoForms/ and for get data from the forms see here. https://our.umbraco.org/documentation/Products/UmbracoForms/Developer/Working-With-Data/

    Hope this helps,

    /Dennis

  • Jonas 123 posts 206 karma points
    Mar 13, 2015 @ 10:26
    Jonas
    0

    Hi Dennis,

    Well the documentation is not up to date. This is what I have so far, and I am trying to get the value from the fields in the form, they ar named:

    "Your Name" "Email" "Comment"

    @{

    string formGuid = Model.Content.GetPropertyValue("messageBoardFormGuid", true).ToString();
    

    }

            @{
                DynamicRecordList records = Library.GetRecordsFromForm(formGuid);
                <div>
    
                    @foreach (DynamicRecord record in records.Items)
                    {
                        <div>
                            @record.Created.ToString("dd MMMM yyy")<br />
                         </div>
                    }
                </div>
            }
    
  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Mar 13, 2015 @ 10:35
    Dennis Aaen
    1

    Hi Jonas,

    What if you do something like this would this give you the value of the fields.

    @{
        string formGuid = Model.Content.GetPropertyValue("messageBoardFormGuid", true).ToString();
    }

    @{
        DynamicRecordList records = Library.GetRecordsFromForm(formGuid);
        <div>

            @foreach (DynamicRecord record in records.Items)
            {
                <div>
                    @record.YourName
                    @record.Email
                    @record.Comment
                    @record.Created.ToString("dd MMMM yyy")<br />
                 </div>
            }
        </div>
    }

    Hope this helps,

    /Dennis

  • Jonas 123 posts 206 karma points
    Mar 13, 2015 @ 10:49
    Jonas
    0

    Thanks, that works..

    I am using

    "Your name" "Email, phone or room number" "Message"

    "Message" is no problem picking up.

    But the others with space in the name are harder to find..

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Mar 13, 2015 @ 23:19
    Dennis Aaen
    100

    Hi Jonas,

    Perhaps you already has found the solution if not, then when you have a field with spaces you can get the value like this.

    @record.GetField("Your Name").Values[0] 

    Where you need to add the caption of the field in the GetField.

    @{
        @using Umbraco.Forms.Mvc.DynamicObjects
        string formGuid = Model.Content.GetPropertyValue("messageBoardFormGuid",true).ToString();
    }

    <ul id="comments">
        @foreach (dynamic record in Library.GetRecordsFromForm(formGuid)){
            <li>
                @record.Created.ToString("dd MMMM yyy")<br />
                @record.GetField("Your Name").Values[0]<br />
                @record.Email<br />
                @record.GetField("Comment").Values[0]<br />
         </li>
     }
    </ul>

    Hope this helps,

    /Dennis

  • Jonas 123 posts 206 karma points
    Mar 16, 2015 @ 08:18
    Jonas
    0

    Hi Dennis,

    Absolutely great, thanks alot!

    :-)

Please Sign in or register to post replies

Write your reply to:

Draft