Copied to clipboard

Flag this post as spam?

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

  • Wing 17 posts 39 karma points
    Jul 14, 2014 @ 10:26

    Razor Record.HasField() always return true


    I've a weird problem using razor script in Umbraco 4.11.7 with Contour

    See following code:

    var form = new DynamicForm(formId);
    var cRecords = form.Records.Items.Where(x => x.State == Umbraco.Forms.Core.Enums.FormState.Approved);
    foreach (dynamic record in cRecords)
      var check = record.HasField("Comment");

    No matter what value I pass to HasField, it always returns true, even if it doesn't exist nor has exist before. If I do the following check after the previous one:

    record.GetField("Comment") != null

    Obviously it will throw error if it doesn't exist.

    Anyone else has this problem?

    Thanks for reading.

Please Sign in or register to post replies

Write your reply to: