Search code examples
c#dynamics-crmdynamics-crm-2013dynamics-crm-online

how to get blocked file extensions and maximum file size for attachment in dynamics crm using c# code


I want to get blocked file extension and maximum file size for attachment set by admin in c# code .Below image displays what I actually want using c# code.

enter image description here

enter image description here

Please suggest me answer.


Solution

  • Try using below code, it is tested and working fine.

     var  query = new QueryExpression("organization")
                    {
                        ColumnSet = new ColumnSet("blockedattachments", "maxuploadfilesize")
                    };
                    var record = service.RetrieveMultiple(query).Entities.FirstOrDefault();
    
                    if (record != null)
                    {
                        var blockedAttachments = record.GetAttributeValue<string>("blockedattachments");
                        var maxAttachmentSize = record.GetAttributeValue<int>("maxuploadfilesize");
                    }