locked
max value of a integer field in mscrm 2011 RRS feed

  • Question

  • Dear All;

    i want to get the max value of integer field on a form through plugin or the record which the last record added in the form through plugin in mscrm 2011

    Tuesday, July 3, 2012 11:01 AM

Answers

  • hi try this one in your plugin


        

    QueryExpression query = new QueryExpression() { EntityName="quote", ColumnSet = new ColumnSet() { "productcounter"}, }; query.Criteria.AddCondition(new ConditionExpression() { AttributeName="productcounter", Operator=ConditionOperator.NotNull }); query.AddOrder("productcounter",OrderType.Descending); var resEntities = service.RetrieveMultiple(query);

    var productNo=(int)resEntities.Entities[0]["productcounter"]+10;

    //assign for new record




             



    By Sanz. -- If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".

    • Proposed as answer by san Sanz Friday, July 6, 2012 9:49 AM
    • Marked as answer by anwar_addi Friday, July 6, 2012 11:40 AM
    Friday, July 6, 2012 9:49 AM

All replies

  • I suspect you would get a quicker answer in the CRM Development forum

    Hope this helps. Adam Vero, Microsoft Certified Trainer | Microsoft Community Contributor 2011

    Wednesday, July 4, 2012 10:36 AM
  • Hi 

    Please refer this link for 

    http://msdn.microsoft.com/en-us/library/gg309435.aspx

    Thanks & regards

    Dhamodharan R 

    Wednesday, July 4, 2012 12:20 PM
  • Hi anwar your question is unclear.

    are you talking about get a record which contains a filed having max value than all?


    By Sanz. -- If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".

    Wednesday, July 4, 2012 12:25 PM
  • Hi San ;

    yes you are right let me explain you the scenario i have a counter field for all quote products so when i add new product the counter should add 10 to the max number for example if the max number in that field 100 so the new counter number for the new added product would be 110

    Friday, July 6, 2012 7:45 AM
  • hi try this one in your plugin


        

    QueryExpression query = new QueryExpression() { EntityName="quote", ColumnSet = new ColumnSet() { "productcounter"}, }; query.Criteria.AddCondition(new ConditionExpression() { AttributeName="productcounter", Operator=ConditionOperator.NotNull }); query.AddOrder("productcounter",OrderType.Descending); var resEntities = service.RetrieveMultiple(query);

    var productNo=(int)resEntities.Entities[0]["productcounter"]+10;

    //assign for new record




             



    By Sanz. -- If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".

    • Proposed as answer by san Sanz Friday, July 6, 2012 9:49 AM
    • Marked as answer by anwar_addi Friday, July 6, 2012 11:40 AM
    Friday, July 6, 2012 9:49 AM