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

Minimum/Maximum number of the field

$
0
0

Hi, i need to get the maximum and minimum number of related products on project according to a decimal field using any help?

the below code is not setting the true max number and not setting the min value:

foreach (var RelatedProductsRecords in RelatedProductsEntity.Entities)
                    {
                        var Total= RelatedProductsRecords .GetAttributeValue<decimal>("new_totalarea");
                        log.Info("prod Size= " + Total);

                        decimal highestFound = decimal.MaxValue;
                        log.Info("highestFound= " + decimal.MaxValue);
                   
                        decimal lowestFound = decimal.MinValue;
                        log.Info("lowestFound= " + decimal.MinValue);
 
                        if (Total> highestFound)
                        {
                            highestFound = TotalCoveredArea;
                            log.Info("Maximum pro Size= " + Total);

                            ProjectEntity.Attributes["new_sizetorange"] = highestFound;
                            log.Info("product size To = " + highestFound);

                            service.Update(ProjectEntity);
    
                        }

                        if (Total< lowestFound)
                        {
                            lowestFound = Total;
                            log.Info("Minimum Apartment Size= " + Total);

                            ProjectEntity.Attributes["new_sizefromrange"] = lowestFound;
                            log.Info("product size from = " + lowestFound);

                            service.Update(ProjectEntity);
                        }
}

Viewing all articles
Browse latest Browse all 46379

Trending Articles



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