Copied to clipboard

Flag this post as spam?

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


  • Mikkel Olsen 20 posts 94 karma points
    Aug 02, 2013 @ 15:25
    Mikkel Olsen
    0

    Does old version of contour handle Forms data differently?

    Hello all..

    I have recently created a custom workflow that populates data from any given form to an e-mail. I made a switch statement in C# to handle the different field types, which is working absolutely fine.

    However, I got another website where I need to implement the same kind of functionality but not getting the results as expected.

    In both cases I have 2 dropdownlists which retrives its data from Umbraco Documents - Simply a Node containing some childnodes on the content tab like this:

    Site

    -- Companies

    --- 1100 Company A -> txtstring email (property)

    --- 1200 Company B -> txtstring email (property)

    and so on..

    So I got the list to show "1100 Company A" just like I did in the earlier project.. However, when I try to loop the Form's fields it cannot populate the actual selected data in the dropdownlist, only the "ID" even though I am using the excact same code as earlier.

    I have debugged a lot and the code is not different from the "working" one it keeps populating the ID even though it "shouldnt".. Could it be something to do with the version of contour installed on the website?

    I can say the package contour on the website (i cant see the version number on the backend) is 1.12 (which I reckon is quite old)

    Anyways, I would appreaciate any help or thoughts in the subject.. Sample code to handle the population is as follows:

      public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
            {
               
                //List<object> list to hold the objects - listTwo contains the caption e.g. Postnummer, Date etc
                List<object> list = new List<object>();
                List<object> listTwo = new List<object>();
                foreach (RecordField rf in record.RecordFields.Values.OrderBy(f => f.Field.SortOrder))
                {
                   
                    if (rf.Values.Any() && rf.Values[0] != null && !string.IsNullOrWhiteSpace(rf.Values[0].ToString()))
                    {
                        //switch statement that checks whether the contour fields are equal to any of the listed ones. In that case, add the selected value to the List.
                        switch (rf.Field.FieldType.ToString())
                        {
                            case "Umbraco.Forms.Core.Providers.FieldTypes.RadioButtonList":
                            case "Umbraco.Forms.Core.Providers.FieldTypes.CheckBoxList":
                            case "Umbraco.Forms.Core.Providers.FieldTypes.DropDownList":
                            case "Umbraco.Forms.Core.Providers.FieldTypes.Textarea":
                            case "Umbraco.Forms.Core.Providers.FieldTypes.Textfield":
                            case "Umbraco.Forms.Core.Providers.FieldTypes.CheckBox":
                            case "Umbraco.Forms.Core.Providers.FieldTypes.DatePicker":
                            string selectedId = rf.Values[0].ToString();
                                string selectedCaption = rf.Field.Caption;
                                    list.Add(selectedId);
                                    listTwo.Add(selectedCaption);
                                    break;
                        }
                       
                    }
                }

  • Comment author was deleted

    Aug 05, 2013 @ 12:48

    Yeah think there is a small difference when using fieldtypes that use prevalues and the value that get's stored

  • Mikkel Olsen 20 posts 94 karma points
    Aug 05, 2013 @ 14:35
    Mikkel Olsen
    0

    Do you have any idea on how to accomplish the before-written issue? Is there an easy way to retrieve the value from the dropdownlist? :)

  • Comment author was deleted

    Aug 05, 2013 @ 14:42

    Yeah there should be a valuesAsString property that you can use

  • Mikkel Olsen 20 posts 94 karma points
    Aug 05, 2013 @ 14:57
    Mikkel Olsen
    0

    So just something like.. ValueAsString("id of dropdownlist here"); ? :-)

  • Comment author was deleted

    Aug 05, 2013 @ 15:01

    think something like rf.ValuesAsString in your example code

  • Mikkel Olsen 20 posts 94 karma points
    Aug 05, 2013 @ 15:03
    Mikkel Olsen
    0

    Ah right.. Will give it a shot, thanks for your time, Tim

  • Mikkel Olsen 20 posts 94 karma points
    Aug 08, 2013 @ 08:45
    Mikkel Olsen
    0

    Sorry Tim, I am still getting the ID and not the actual text data :(

     

  • Comment author was deleted

    Aug 08, 2013 @ 09:27

    Hmm that's strange, did you customize the fieldtype view?

  • Mikkel Olsen 20 posts 94 karma points
    Aug 08, 2013 @ 09:34
    Mikkel Olsen
    0

    I am not sure I understand what you mean by customize the fieldtype view - The contour form is basically just a created form with different fieldtypes. I really dont see the logic in it taking the ID, when I actually point at the value.. It is strange indeed. However, if there is an easier way to obtain the data from a dropdown list which data is being loaded from a prevalue source -> umbraco document etc. I would appreaciate it. Note that the thing I am doing (code above) might not be the correct way to do this :-)

     

     

  • Comment author was deleted

    Aug 08, 2013 @ 09:37

    Will check why you get the id but as a temp workaround you can use

    using (Umbraco.Forms.Data.Storage.PreValueStorage pvs = new Umbraco.Forms.Data.Storage.PreValueStorage()) {

    var val = pvs.GetPreValue(newGuid(Country)).Value

    }

Please Sign in or register to post replies

Write your reply to:

Draft