acumaticabusiness-logic

How does one access an Extension to a table in Acumatica Business Logic


Apologies if this question has been answered elsewhere, I have had trouble finding any resources on this. The scenario is this. I have created a custom field in the Tax Preferences screen called Usrapikey. This value holds an api key for a call that gets done in some custom business logic. The custom business logic however occurs on the Taxes screen. So within the event handler I need to access that API key value from the other screen. I have tried instantiating graphs and using linq and bql but to no avail. below is what I have currently and my error is: No overload for method 'GetExtension' takes 1 arguments

If I am going about this the wrong way please let me know if there is a more civilized way to do this

protected virtual void _(Events.FieldUpdated<TaxRev, TaxRev.startDate> e)

   {

  var setup = PXGraph.CreateInstance<TXSetupMaint>();
  var TXSetupEX = setup.GetExtension<PX.Objects.TX.TXSetupExt>(setup);

  var rateObj = GetValues(e.Row.TaxID, TXSetupEX.Usrapikey);
  decimal rate;

  var tryRate = (Decimal.TryParse(rateObj.rate.combined_rate, out rate));
  row.TaxRate = (decimal)rate * (decimal)100;
  row.TaxBucketID = 1;

  }

Many Thanks!


Solution

  • Well, acumatica support got back. It seems if you want to access the base page use:

        TXSetup txsetup = PXSetup<TXSetup>.Select(Base);
    

    To get the extension use:

        TXSetupExt rowExt = PXCache<TXSetup>.GetExtension<TXSetupExt>(txsetup);
    

    Then you can access the extension fields like so:

        var foo = rowExt.Usrfield;