web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Quote entity

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Suggested answer
    Alagunellaikumar Profile Picture
    6,212 on at

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

  • Community Member Profile Picture
    on at

    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
    6,212 on at

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

  • Community Member Profile Picture
    on at

    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

  • Community Member Profile Picture
    on at

    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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans