public List<AccountEntityModels> RetriveRecord()
{
using (OrganizationService service = new OrganizationService("MyConnectionString"))
{
QueryExpression query = new QueryExpression
{
EntityName = "account",
ColumnSet = new ColumnSet("name")
};
List<AccountEntityModels> info = new List<AccountEntityModels>();
EntityCollection accountRecord = service.RetrieveMultiple(query);
if (accountRecord != null && accountRecord.Entities.Count > 0)
{
AccountEntityModels accountModel;
for (int i = 0; i < accountRecord.Entities.Count; i++)
{
accountModel = new AccountEntityModels();
if (accountRecord[i].Contains("name") && accountRecord[i]["name"] != null)
accountModel.AccountName = accountRecord[i]["name"].ToString();
info.Add(accountModel);
}
}
return info;
}
}
how to create Account in dynamics crm using asp.net?
325 Views Asked by San Phan At
1
The above code is for retrieving all the CRM accounts, storing in generic List collection and returning it.
If you want to create an account, use this code.
Read more for samples explained clearly, also about
_serviceinitialization.