Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Quote entity

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi all

Two question if you could help please. Both regarding the quote entity

the first

I have added a column in the sub-grid where you add the products ("quotedetailsGrid") called itemweight this gets the value from the product catalog for the weight of an item ideally i would like this column add work out based on quantity so if there is a quantity of 3 i would like it to multiple the itemweight by 3. I have looked all over the internet and can't find anything 

The second question 

I would like to sum all the above weights to get a quote total weight in the main quote form. I've tried a few ideas from this fourm with no luck. Any pointers would be greatly appreciated

Regards


Dan 

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Quote entity

    Hi all I've had another play and i will admit i am new to all of this. From what i understand some code like below is what i'm trying to do. Ive changed what i think i needed to change namewise and added the steps as detailed in the orgianl code discussion Postcreate, Postupdate buti still can't seem to figure it out could one of you nice people point me in the right direction.

    My fields and entitys are as follows

    Parent Ent -quotes

    Child - quotedetailsgrid

    Column with in gris is - new_Itemweight

    Field on parent for where i want the data is - new_totalweight

    This is the code i'm trying to use

       public class SumWeight : IPlugin

       {

           public void Execute(IServiceProvider ServiceProvider)

           {

               IPluginExecutionContext Context = (IPluginExecutionContext)ServiceProvider.GetService(typeof(IPluginExecutionContext));

               IOrganizationServiceFactory ServiceFactory = (IOrganizationServiceFactory)ServiceProvider.GetService(typeof(IOrganizationServiceFactory));

               IOrganizationService Service = ServiceFactory.CreateOrganizationService(Context.UserId);

               if (Context.PostEntityImages.Contains("PostImage") && Context.PostEntityImages["PostImage"] is Entity)

    {

                   Entity Weight = (Entity)Context.InputParameters["Target"];

                   var WeightTot = (EntityReference)Weight.Attributes["quotedetailsGrid"];

                   decimal Total = FetchResult(WeightTot.Id, Service);

                   // Updating Parent Entity

                   Entity Quote = new Entity("quote");

                   Quote.Id = Weight.Id;

                   Quote["TestWeight"] = 10;

                   Service.Update(Quote);

               }

           }

           private static decimal FetchResult(Guid quantity, IOrganizationService service)

           {

               string value_sum = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false' aggregate='true'>

    <entity name='quotedetailsGrid'>

    <attribute name='ItemWeight' alias='ItemWeight_sum' aggregate='sum'/>

    <filter type='and'>

     <condition attribute='ItemWeight' operator='eq' value='{0}' />

     </filter>

     </entity>

     </fetch>";

               decimal TotalValue = 0;

               value_sum = string.Format(value_sum, quantity);

               EntityCollection value_sum_result = (EntityCollection)service.RetrieveMultiple(new FetchExpression(value_sum));

               foreach (var c in value_sum_result.Entities)

               {

                   decimal aggregate2 = ((int)((AliasedValue)c.Attributes["ItemWeight_sum"]).Value);

                   TotalValue = aggregate2;

               }

               return TotalValue;

           }

       }

    }

    may thanks for your help

    Cheers

    Dan

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Quote entity

    Hi All

    I still Can't get my head round this everything i have tried doesn't seem to work various plugin's and js. Does anyone have examples and advice for 2016

    Regards

    Dan

  • Suggested answer
    Alagunellaikumar Profile Picture
    Alagunellaikumar 6,210 on at
    RE: Quote entity

    If you find your answer, could you please mark as verified

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Quote entity

    Hi

    Thank you for the reply

    That is kind of the idea i was looking at. I was just after a point in the right direction on how to write the guts of it. I'm pretty new to the CRM Scene but getting there slowly

    Many Thanks

    Dan

  • Suggested answer
    Alagunellaikumar Profile Picture
    Alagunellaikumar 6,210 on at
    RE: Quote entity

    Why don't you write plugin, configured post operation for  "quote product"?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans