locked
Plug-In for updating a quotes total amount RRS feed

  • Question

  • Hello together,

    I was wondering if there is a possibility to write a plug-in which manipulates the total amount of a quote. The business case is, that we want to have "optional" products or alternatives to products in the quote which should not increase the total amount of the quote. So we want to decrease the total amount by the optional products value using a plug-in. So far, so good. Now we face the problem, we have written a plug-in to change the value and registered it on the update message of the quote entity. But how could we achieve that the total amount is really changed? If we use the post-image and change the total amount, we have to write it back to the database in some way. If we use the update-method of the ICrmService retrieved from the context to change the value the common update procedure of MS CRM is called and the TotalAmount is recalculated and overwritten using the products. Now our plug-in is called, but we have the same value like before the first plug-in call. So now we can decide to run in an infinite loop or to do nothing with our plug-in to prevent the loop.

    Has anyone a suggestion how to solve the problem? An idea would be to create an user-defined attribute for the manipulated total amount. But this questions also aims in the direction if it is possible in any way to maniplulate crm common calculations?

    Thanks and best regards,
    Florian 
    Monday, March 1, 2010 4:14 PM

Answers

  • Hi i am not sure, but i think updating the totalamount of the quote is not a supported function as per the sdk. see the description of the attribute.

    quote.totalamount Property

    Gets the total amount for the quote.

    Syntax

    [Visual Basic .NET]
    Public Property totalamount As CrmMoney
    [C#]
    public CrmMoney totalamount {get; set;}

    Property Value

    The value of this property is a CrmMoney type.

    Remarks

    The following table contains additional information about this property:

    Platform required No
    Application requirement level Read-only
    Valid for create No
    Valid for retrieve Yes
    Valid for update No
    Precision 2
    Minimum value -922,337,203,685,477.00
    Maximum value 922,337,203,685,477.00


    Muhammad Ali Khan
    My MS CRM blog
    • Marked as answer by - Florian - Tuesday, March 2, 2010 9:12 AM
    Monday, March 1, 2010 4:20 PM
  • As stated above, the totalamount property is read-only, additionally there is no way to modify the built-in calculations. You're probably best off using custom attributes to store the results of your calculations
    Microsoft CRM MVP - http://mscrmuk.blogspot.com  http://www.excitation.co.uk
    • Marked as answer by - Florian - Tuesday, March 2, 2010 9:12 AM
    Monday, March 1, 2010 8:39 PM
    Moderator

All replies

  • Hi i am not sure, but i think updating the totalamount of the quote is not a supported function as per the sdk. see the description of the attribute.

    quote.totalamount Property

    Gets the total amount for the quote.

    Syntax

    [Visual Basic .NET]
    Public Property totalamount As CrmMoney
    [C#]
    public CrmMoney totalamount {get; set;}

    Property Value

    The value of this property is a CrmMoney type.

    Remarks

    The following table contains additional information about this property:

    Platform required No
    Application requirement level Read-only
    Valid for create No
    Valid for retrieve Yes
    Valid for update No
    Precision 2
    Minimum value -922,337,203,685,477.00
    Maximum value 922,337,203,685,477.00


    Muhammad Ali Khan
    My MS CRM blog
    • Marked as answer by - Florian - Tuesday, March 2, 2010 9:12 AM
    Monday, March 1, 2010 4:20 PM
  • As stated above, the totalamount property is read-only, additionally there is no way to modify the built-in calculations. You're probably best off using custom attributes to store the results of your calculations
    Microsoft CRM MVP - http://mscrmuk.blogspot.com  http://www.excitation.co.uk
    • Marked as answer by - Florian - Tuesday, March 2, 2010 9:12 AM
    Monday, March 1, 2010 8:39 PM
    Moderator
  • Thanks a lot for the fast confirmations. So the only way will be to use custom defined fields. As well as the second information (that you can't modify built-in procedures) is really good to know.
    Tuesday, March 2, 2010 9:12 AM