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?
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:
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
and other things, but I haven't found the solution yet. Can you help?
Cheers!
David
Hmm, can't seem to edit, meant that to be a check for null, instead of two calls to HasValue()!
Comment author was deleted
Could you try
if record.RecordFields.Any(x=> x.Value.Field.Caption == "FieldCaption")
Hi Tim,
That works a treat. Thanks!
David
is working on a reply...