locked
Auto Numbers for Custom Entity!!!!!!!!!! RRS feed

  • Question

  • Hi Guys, This is the one code for System Entity to generate Auto Numbers.....But i want the Auto Number to be generated for Custom Entity.... Custom entity---->>>> Customer Details Custom Attribute ------>>> new_customerId So i want to generate Auto Numbers in new_customerId attribute which is custom Attribute... Kindly Help...... ***************************************************************************************** ColumnSet cols = new ColumnSet(); cols.AddColumns(new string[] { "leadid", "new_autonumber" }); PagingInfo pages = new PagingInfo(); pages.PageNumber = 1; pages.Count = 1; QueryExpression query = new QueryExpression(); query.EntityName = EntityName.lead.ToString(); query.ColumnSet = cols; query.AddOrder("new_autonumber", OrderType.Descending); query.PageInfo = pages; RetrieveMultipleRequest request = new RetrieveMultipleRequest(); request.ReturnDynamicEntities = true; request.Query = query; RetrieveMultipleResponse retrieved = (RetrieveMultipleResponse)service.Execute(request); if (retrieved.BusinessEntityCollection.BusinessEntities.Count > 0) { DynamicEntity results = (DynamicEntity)retrieved.BusinessEntityCollection.BusinessEntities[0]; if (results.Properties.Contains("new_autonumber")) { nextNumber = Convert.ToInt32(results.Properties["new_autonumber"].ToString()) + 1; //add nextNumber as the entity property for the coresponding entity } } ******************************************************************************************** Thanks
    Believe in yourself!!!!!!!!!!!!
    Tuesday, October 26, 2010 7:43 AM

Answers