Monday, 26 March 2018

CRM 365 Getting Current User ID and name


Getting User Details :

var userName = Xrm.Page.context.getUserName();
var userGUID = Xrm.Page.context.getUserId();
alert ("User is:" + userName + "nGUID is:" + userGUID);

Thursday, 8 March 2018

Retrieve more than 5000 records using FetchXML in Dynamic CRM

 Sample Code:

string fetchXMLInvoice = @"<fetch version='1.0' page='{0}' paging-cookie='{1}' count='5000' output-format='xml-platform' mapping='logical' distinct='false'>
  <entity name='tec_invoice'>
    <attribute name='tec_invoiceid' />
    <attribute name='tec_name' />
    <attribute name='createdon' />
    <order attribute='tec_name' descending='false' />
    <filter type='and'>
      <condition attribute='createdon' operator='on-or-after' value='2017-01-01' />
      <condition attribute='createdon' operator='on-or-before' value='2018-01-01' />
    </filter>
  </entity>
</fetch>";

            int page = 1;           
            string pageCookies = "";
            EntityCollection result = new EntityCollection();
            do
            {
var fetchXML=   new FetchExpression(String.Format(fetchXMLInvoice, page++, pageCookies));
                result = service.RetrieveMultiple(fetchXML);
                pageCookies = System.Net.WebUtility.HtmlEncode(result.PagingCookie);             

            } while (result.MoreRecords);