Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Unanswered

Edit Total Tax on Quotes

Posted on by 299

Hi there,

The scenario is that I want to have tax on quote not in quote line items.(as you know the field is disabled) I created a decimal field "percent of the tax" that may have vales 0 or 9, then with the code below I calculate total tax and update it,

but it doesn't get updated. Any Ideas?

        public string IntenalExcuter(IOrganizationService orgsrv, EntityReference quote)
        {

            Entity quoteEnt = orgsrv.Retrieve(quote.LogicalName, quote.Id, new ColumnSet("totallineitemamount","totaltax","new_taxpercent", "new_customtax"));
            string message = "";
            Entity updateEntity = new Entity(quote.LogicalName);
            updateEntity.Id = quote.Id;
            decimal totallineitemamount = quoteEnt.GetAttributeValue("totallineitemamount").Value;
            decimal taxpercent = quoteEnt.GetAttributeValue("new_taxpercent") / 100;
            decimal amount = totallineitemamount * taxpercent ;
            updateEntity["new_customtax"] = new Money(amount);
            updateEntity["totaltax"] = new Money(amount);
            try
            {
                orgsrv.Update(updateEntity);
            }
            catch (Exception e)
            {

                message= e.Message;
            }

            return message;
        }

Best Regards

Sam

Categories:
  • z.sam Profile Picture
    z.sam 299 on at
    RE: Edit Total Tax on Quotes

    Thanks for your reply Esteban,

    I don't really know what's the difference between these two syntax.

    updateEntity.Attributes["new_customtax"]

    updateEntity["new_customtax"]

    I don't get syntax error also,

    Regards

  • RE: Edit Total Tax on Quotes

    Hello, I think that you are missing the "AttributeCollection" on line 11 and 12, try this:

    updateEntity.Attributes["new_customtax"] = new Money(amount);

    updateEntity.Attributes["totaltax"] = new Money(amount);

    Thanks!

    Community Support Team - Esteban

    If this Post helps, then please consider Accept as solution to help the other members find it more quickly.

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,532 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,501 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans