Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

Edit Total Tax on Quotes

(0) ShareShare
ReportReport
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

  • z.sam Profile Picture
    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

  • Esteban Coto Alfaro Profile Picture
    on at
    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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,688 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,643 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans