Copied to clipboard

Flag this post as spam?

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


  • Simon steed 359 posts 668 karma points
    Oct 27, 2011 @ 11:51
    Simon steed
    0

    Contour records randomly swapping over

    Strange one this. I've got a form with a Name and Email field setup. This gets submitted into Contour and then the page redirects to my user control page with the recordid as a query string param.

    So far so good. Now I am trying to access the submitted data based upon the recordid so I pass into the following method:

    public string ConvertRecord(string recordID)
            {
                // for testing only
                //recordID = "bf986387-566d-4743-aa78-6bbaacaeb59f";
    
                if (recordID != "")
                {
                    RecordStorage rs = new RecordStorage();
                    Record r = rs.GetRecord(new Guid(recordID));
                    
                    RecordsViewer viewer = new RecordsViewer();
                    XmlNode xml =  viewer.GetSingleXmlRecord(r, new System.Xml.XmlDocument());
    
                    string email = "";
                    string name = "";
    
                    foreach (KeyValuePair<System.Guid, Umbraco.Forms.Core.RecordField> field in r.RecordFields)
                    {
                        if(email == string.Empty)
                            email = field.Value.Values[0].ToString();
                        else
                            name = field.Value.Values[0].ToString();
                        
                    }
    
                    return name + "," + email;
                }
                return string.Empty;
            }
    What it should do is give me a string in the format "simon steed,[email protected]".

    The problem is sometimes it does, sometimes it doesnt. I am getting strange things like the email and name are swapped around. How can I stop this or is there a better way to get this data?

    Cheers

    Si
  • Simon steed 359 posts 668 karma points
    Oct 31, 2011 @ 10:09
    Simon steed
    0

    Nobody tried doing anything like this before?

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Oct 31, 2011 @ 10:20
    Tim Geyssens
    0

    And does the data get stored properly or also getting the swap effect there?

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Oct 31, 2011 @ 10:22
    Tim Geyssens
    0

    Think you should just add an additional check to get the correct field first (based on the caption)... since now it's just based on the order 

  • Simon steed 359 posts 668 karma points
    Oct 31, 2011 @ 10:27
    Simon steed
    0

    Hi Tim - Data seems to be stored correctly so not worried there, just randomly returns alternate data on different calls to get the record.

    I was originally wondering if there was a better way to get at the data, I guess i'm using the correct methods then?

    I'll try adding some additional logic, cheers :-)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies