Copied to clipboard

Flag this post as spam?

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


  • David Conlisk 432 posts 1008 karma points
    Nov 22, 2012 @ 15:28
    David Conlisk
    0

    Custom workflow - test if RecordField exists

    Hi all,

    I have two versions of a newsletter signup form, one with just a couple of fields (basic version) and one with lots of extra fields (advanced version). Ideally, I'd like to use the same custom workflow for both. So I need to check if a given recordfield exists before using it (in my case I'll be sending it to dotMailer).

    I want to do this:

    if (record.GetRecordField("Town").HasValue()) { // do stuff }

    But it keeps giving me and InvalidOperationException: Sequence contains no elements (which is swallowed at some point, so the user never sees it, you only see it when debugging with VS).

    I've played about with it, tried

    record.GetRecordField("Town").HasValue

    and other things, but I haven't found the solution yet. Can you help?

    Cheers!

    David

  • David Conlisk 432 posts 1008 karma points
    Nov 22, 2012 @ 15:33
    David Conlisk
    0

    Hmm, can't seem to edit, meant that to be a check for null, instead of two calls to HasValue()!

    if (record.GetRecordField("Town") != null)
  • Comment author was deleted

    Nov 23, 2012 @ 10:32

    Could you try

    if record.RecordFields.Any(x=> x.Value.Field.Caption == "FieldCaption")

  • David Conlisk 432 posts 1008 karma points
    Nov 23, 2012 @ 16:45
    David Conlisk
    0

    Hi Tim,

    That works a treat. Thanks!

    David

Please Sign in or register to post replies

Write your reply to:

Draft