Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Auto-Numbering Account Entities on Import

$
0
0

Is there a way to have auto-numbering for the Account entity while using the standard import tool? I currently have a plugin to do this, but as you can see from the code below, it gets VERY inefficient as the number of accounts increases. What it's basically doing is searching through all the accounts to find the maximum number and incrementing it by 1 - the problem is that it's searching through the entire list after every new account is added.

var maxNumber = 1;
foreach(var account in accounts)
{
   int j;
   if(int.TryParse(account.AccountNumber, out j))
   {
      if(maxNumber < j)
      {
         maxNumber = j;
      }
   }
}
Target.AccountNumber = (maxNumber + 1).ToString();
ArsOrganizationContext.SaveChanges();

I see that there are paid versions available but I was looking for non-paid solutions. Currently using Dynamics Online 2016 Update 1. 


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>