Provide Default Value for Report Parameter from Branch

Hi All,

Really often you may want to have some default values for report parameters, that may depend on environment. For example different default warehouse depend on branch where are you working now. Or different warehouse depend on current employee.

But unfortunately it is not out of the box functionality in Acumatica.
Luckily, using powerful Acumatica Customization engine it is quite easy to do. Let me share with you a way to archive it.

Scenario: lets assume that we want to have different default warehouse on Inventory Valuation report based on different branch that is selected as current.

We will do this task in 3 steps:

  1. Adding custom field to link branch and warehouse
  2. Create a class that can evaluate required warehouse by currently selected branch
  3. Provide default parameter in report

Step 1: Adding custom field to Branch screen.
To store association between Branch and Warehouse we need to add new field there. To do this, please follow the instruction and image attached:

  1. Create a customization project
  2. Open Branches screen
  3. Select tab with branch configurations
  4. Create new custom field
  5. Adjust attributes of custom field like here:
    1. [Site()]
  6. Publish customization
  7. Refresh page
  8. Create a control on the page from custom field. Make sure that you have selector
  9. Publish customization once again

Customization extension is here:

public class BAccountExt : PXCacheExtension<PX.Objects.CR.BAccount>
        #region UsrDefaultWarehouse
        public virtual int? UsrDefaultWarehouse { get; set; }
        public abstract class usrDefaultWarehouse : IBqlField { }

Step 2: Creating a new virtual DAC for providing default values to report.
We need to have a object that will evaluate a warehouse based on currently selected branch. So here we need to create an data access class with auto-calculated field:

public class ReportsDefault : IBqlTable
       #region UsrDefaultWarehouse
              InnerJoin<Branch, On<Branch.bAccountID, Equal<BAccount.bAccountID>>>,
              Where<Branch.branchID, Equal<Current<AccessInfo.branchID>>>>))]
       public virtual int? UsrDefaultWarehouse { get; set; }
       public abstract class usrDefaultWarehouse : IBqlField { }

Do not forget to publish project after adding an new DAC.

The key point here is AccessInfo class, that provides us access to current environment variables. Here you can see list of all usable variables:

  • BaseCuryID – ID of the base currency implemented in current tenant
  • BranchID – currently selected branch.
  • BusinessDate – business that that was selected on top of Acumatica main page
  • ScreenID – ID of current screen
  • UserID – ID of currently logged it user.

For calculation your defaults you can use any of these fields. Employee usually is linked to user, so you can evaluate current employee by user name.

Step 3: Default value for report parameter
Lets open required report and select warehouse parameter on Build Schema form.
To provide default value we just need to link the parameter and the new DAC. Report.GetDefExt will call DAC business logic and will automatically evaluate value accordingly to formula specified in step 2.


That is all. Now you can test it!

Code snippet:

Have a nice development!

Leave a Reply

Your email address will not be published. Required fields are marked *