Posts

Showing posts with the label Dynamics CRM 365 Code Snippet

Dynamics 365 paging with fetchxml

Dynamics 365 web service has limitation to return 5000 records in a single web service call. Many a times we get the requirement to fetch more than 5000 records to meet the business requirement. Microsoft has provided the concept of paging where we can get the data returned in multiple pages. We can make use of paging and page cookie to get more then 5000 record. Below code snippet will help you achieve this. public List<Entity> GetRecordsByFetchXml(IOrganizationService service, String fetchXML)         {             List<Entity> objList = new List<Entity>();             try             {                 // Define the fetch attributes.                 // Set the number of records per page to retrieve.                 int fetchCount = 500; ...

Dynamics 365 Check User has Send As Privilege programatically

Business Requirement :- Many a times in our project we get the requirement to check if logged user has Send As privilege allowed in his personal setting programatically. We can use below code snippet to check the logged in user personal settings from plugin code. public bool CheckUserSendAsPrivilege(IOrganizationService service, Guid userGuid)         {             try             {                 if (userGuid != Guid.Empty)                 {                     QueryExpression queryUserSettings = new QueryExpression(UserSettings.EntityLogicalName);                     queryUserSettings.NoLock = true;                     queryUserSettings.Criteria.AddCondition(UserSettings.systemus...

Dynamics 365 Sample Code to set null value for all data types using c#

Recently we had a requirement to set null value for all data types field from C# as part of our integration. I tried searching on internet but couldn't find proper documentation or sample code for all data types field. So i decided to try using console utility and also wanted to share with CRM communities. Sample Code Snipped                 Entity objLead = new Entity("lead");                 objLead.Id = Guid.Parse("Record GUID");                 //Currency                 //objLead["ims_loanamount"] = null;                 //Decimal                 //objLead["ims_loanrate"] = null;                 //Datetime                 //objLead["ims_birt...