Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

Calculation of Money/Currency Field

$
0
0

I need to fetch all related quote products under the quote entity. I used a query expression for this to retrieve the corresponding Total amount for each product. Now I need to sum the total amounts. My code is not working, the field I’m retrieving is a money/currency field.

 

My code goes like this:

 

                        Guid RecordGuid = entity.GetAttributeValue<Guid>("quoteid");

 

                        QueryExpression query = new QueryExpression("quotedetail");

                        query.ColumnSet = new ColumnSet(new string[] { "nexus_marginalamount", "baseamount"});

                        query.Criteria.AddCondition("quoteid", ConditionOperator.Equal, RecordGuid);

                        query.PageInfo.ReturnTotalRecordCount = true;

 

                        EntityCollection result = service.RetrieveMultiple(query);

                        

                        Money  m = new Money ();

 

                        foreach (Entity EntityResult in result.Entities)

                        {

 

                           m = m + EntityResult.GetAttributeValue<Money>("nexus_marginalamount");

 

                        }

 

                        entity["nexus_marginalamount"] = new Money(m.Value);


Viewing all articles
Browse latest Browse all 8223

Trending Articles



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