Copied to clipboard

Flag this post as spam?

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


  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Mar 07, 2011 @ 14:13
    Matt Brailsford
    0

    RecordField.ValuesAsString() and custom PreValue Source Type

    Hey Guys,

    I've implemented this Custom PreValue Source Type in my project:

    http://www.nibble.be/?p=86

    It works great, exept for when I want to render out the selected values of a dropdown list using that prevalue source via the RecordField.ValuesAsString() method. When I do this, I just get the ID's of the prevalues rather than the actual string values. Is there something else I need to add to the PreValue source to do this?

    I did try changing the ID filed to also be the same as the Value field, but that didn't work (The form just thought those fields weren't filled in for some reason).

    Anybody got any ideas on how to get this to work?

    Cheers

    Matt

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Mar 07, 2011 @ 14:39
  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Mar 07, 2011 @ 14:47
    Matt Brailsford
    0

    No such luck I'm affraid. Still coming back as the Pre Value ID.

    Matt

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Mar 07, 2011 @ 15:14
    Sebastiaan Janssen
    0

    Alright, have a look at the GetPrevalues methods here and see if that helps, I don't know the exact syntax but you are able to get both the value and the ID's.

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Mar 07, 2011 @ 16:26
    Matt Brailsford
    0

    Not sure if I'm readin it wrong, but based upon your suggestion, are you just recommending I pull back the entire list of pre values and do my own cross referecning rather than using the ValuesAsString() method?

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Mar 07, 2011 @ 17:02
    Sebastiaan Janssen
    0

    Yes, if the ValuesAsString() method doesn't work for custom prevalue sources (sounds like a bug..) thne it would be fairly easy to just iterate through the prevalues and get match the selected values indexes you get back. Don't forget to load the settings either.

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Mar 07, 2011 @ 19:00
    Matt Brailsford
    0

    Ok, I would have rather have gotten ValuesAsStrings to work, but the other method wasn't too hard to get working, and it does work, so job done.

    Cheers

    Matt

  • Yan 36 posts 56 karma points
    Mar 18, 2011 @ 20:15
    Yan
    0

    Hi Matt, how you get this work? I had same issue. for example, belowe the ValuesAsString() will only returen the prevalue sources ID not the value. Is a simple way to do this?

     

    foreach

    (RecordField rf in record.RecordFields.Values)
    { if
    (rf.Field.Caption == "#province"){ provinceTxt = rf.ValuesAsString(); } }

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Mar 18, 2011 @ 21:12
    Matt Brailsford
    0

    Hey Yan,

    I ended up getting all the prevalues, and looping through them:

    fieldvalue.Text = "";
    
    List<PreValue> preValues = field.PreValueSource.Type.GetPreValues(field);
    foreach(object value in recordField.Values)
    {
        foreach(PreValue preValue in preValues)
        {
            if (preValue.Id.ToString() == value.ToString() && preValue.Value.Trim() != "")
            {
                if (fieldvalue.Text != "")
                    fieldvalue.Text += "<br />";
    
                fieldvalue.Text += preValue.Value.Trim();
                continue;
            }
        }
    }   

    It's not the cleanest solution, but works for me.

    Cheers

    Matt

Please Sign in or register to post replies

Write your reply to:

Draft