How to retrieve required fields in an entity that need user to be enter. RRS feed

  • Question

  • Hi there,

    I would like to know from the SDK, how can I retrieve the required fields that user need to enter.

    I have tried AttributeRequiredLevel.ApplicationRequired or AttributeRequiredLevel.SystemRequired but it returns some of the internal fields that user no necessary to enter.


    Friday, May 9, 2014 1:02 AM

All replies

  • I think you should be able to combine this with checking the ValidForCreate and/or ValidForUpdate attributes. The system fields that are SystemRequired, but don't require input (like createdon) will have ValidForCreate and ValidForUpdate = false

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Friday, May 9, 2014 7:53 AM
  • Hi David,

    I have try the logic, in the lead entity, it returns lastname, customeridname, owneridyominame, statecode, owneridname, subject, customeridyominame

                        var requiredFields = from f in entityMetadata.EntityMetadata.Attributes
                                             where  f.RequiredLevel != null &&
                                                    (f.RequiredLevel.Value.Equals(AttributeRequiredLevel.SystemRequired) &&
                                                    f.IsValidForCreate.HasValue && f.IsValidForCreate.Value == false &&
                                                    f.IsValidForUpdate.HasValue && f.IsValidForCreate.Value == false
                                             select f.LogicalName;

    Monday, May 12, 2014 3:00 AM