0

I'm using AvaTax with SteelBrick to calculate tax. Currently I need to click the Calculate Tax button for it to run. I found a workaround to run the calculate but it still depends on clicking a button and using a controller to run the code as listed in this SteelBrick Community forum.

After a a bit of playing around I found a link that is generated when you click on the Calculate Tax button. I copied the link. When I insert the link directly into the address bar it runs the calculation as if the button was clicked. So I created a future callout method with a Http request calling that same url however after runing that method I get status 200 and I dont get any errors. The genrated url I try calling looks like this

https://cs86.salesforce.com/visualforce/session?url=https%3A%2F%2Fsbqqat.cs86.visual.force.com%2Fapex%2Fsbqqat__CalculateQuoteTax%3FscontrolCaching%3D1%26id%3Da2K7E000000zjYYUAY

I need it to run from a trigger and not through a visualforce controller. Any help and ideas are welcome. Thank you

1 Answer 1

1

I know this is a little old, but this might be useful to others. AvaTa has some generic code examples to create a trigger on their website. https://help.avalara.com/001_Avalara_AvaTax/Find_Your_Home_Page/Salesforce/Install_and_Configure_Avalara_AvaTax_for_Salesforce

Here is an example trigger on the opportunity object. This could be modified for the quote or order objects similarly.

trigger Change_AmountTrigger on Opportunity(before update) {             
    for (Integer lc = 0; lc < Trigger.new.size(); lc++) 
     {
       //User's Logic  which will Trigger Tax Calculation comes Here //    
       if (Trigger.new[lc].Amount != Trigger.old[lc].Amount) { 
              //Set values in Tax Now Status and Avalara Status fields should be same as below
              Trigger.new[lc].AVA_SFCORE__Tax_Now_Status__c='Auto Sales Tax Calc Triggered - Refresh Your Browser For Result';  
              Trigger.new[lc].AVA_SFCORE__Avalara_Status__c = 'Temporary';

              //Call Tax Calculation method exposed by Avalara

              //To pass status as Committed
              //AVA_SFCore.OppUtils.AsyncGetTax(Trigger.new[lc].id, true);

              //To pass status as Uncommitted         
              AVA_SFCore.OppUtils.AsyncGetTax(Trigger.new[lc].id, false);     
             }
     }
}
1
  • 6
    please include the essentials of the link, since over time, they may become invalid. Thanks
    – glls
    Mar 24, 2018 at 15:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .