Solved

Filter warehouse by Branch/Company

  • 21 September 2021
  • 3 replies
  • 219 views

Good day

I am trying to filter the warehouse selector on the following screens on the sales and purchase order screen.

This filter would either occur by branch or company based on the users selection on the custom fields brought in on the Inventory preferences screen.

I am not sure how to filter the selector in the graph based on the user selection.

Please see my code attached

        protected void SOLine_BranchID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
{
if (InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (SOLine)e.Row;

INSetupExt extINSetup = row.GetExtension<INSetupExt>();

//retrieve current branch
SOOrder SOOrder = new SOOrder();
var currentSelectedBranch = SOOrder.BranchID;


//See what condition is selected
//If filter by branch is selected, based on the branch selected in the financial tab,
//allow selection of all warehouses linked the transaction branch only
//Else if filter by company is selected,
//allow selection of all warehouses linked to the company or branches within the company associated with the document branch.

if (extINSetup.UsrAllowBlockin == true && extINSetup.UsrByBranch == true)
{
//TODO
}
else if (extINSetup.UsrAllowBlockin == true && extINSetup.UsrByCompany == true)
{
//TODO
}
}
        protected void POLine_BranchID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
{
if (InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (POLine)e.Row;


INSetupExt extINSetup = row.GetExtension<INSetupExt>();

//retrieve current branch
SOOrder SOOrder = new SOOrder();
var currentSelectedBranch = SOOrder.BranchID;

//See what condition is selected
//If filter by branch is selected, based on the branch selected in the financial tab,
//allow selection of all warehouses linked the transaction branch only
//Else if filter by company is selected,
//allow selection of all warehouses linked to the company or branches within the company associated with the document branch.

if (extINSetup.UsrAllowBlockin == true && extINSetup.UsrByBranch == true)
{

}
else if (extINSetup.UsrAllowBlockin == true && extINSetup.UsrByCompany == true)
{
//TODO
}
}

Here is the custom fields DAC’s as well

		#region UsrAllowBlockin
[PXDBBool]
[PXDefault(false)]
[PXUIField(DisplayName="Block Normal Journal Posting by Creator")]

public virtual bool? UsrAllowBlockin { get; set; }
public abstract class usrAllowBlockin : PX.Data.BQL.BqlBool.Field<usrAllowBlockin> { }
#endregion

#region UsrByCompany
[PXDBBool]
[PXDefault(true)]
[PXUIField(DisplayName="By Company")]
[PXUIEnabled(typeof(Where<usrAllowBlockin, NotEqual<False>>))]
[PXUIVisible(typeof(Where<usrAllowBlockin, NotEqual<False>>))]

public virtual bool? UsrByCompany { get; set; }
public abstract class usrByCompany : PX.Data.BQL.BqlBool.Field<usrByCompany> { }
#endregion

#region UsrByBranch
[PXDBBool]
[PXDefault(false)]
[PXUIField(DisplayName="By Branch")]
[PXUIEnabled(typeof(Where<usrAllowBlockin, NotEqual<False>>))]
[PXUIVisible(typeof(Where<usrAllowBlockin, NotEqual<False>>))]

public virtual bool? UsrByBranch { get; set; }
public abstract class usrByBranch : PX.Data.BQL.BqlBool.Field<usrByBranch> { }
#endregion

Any help would be greatly appreciated.

icon

Best answer by Naveen Boga 21 September 2021, 12:55

View original

3 replies

Userlevel 7
Badge +17

Hi @charlbester34  In the above events, you are retrieving the Branch ID in wrong way.

 There are 3 branches available in Sales Order screen. Can you please confirm which one you want to consider. 

  • Login Branch ID
  • Sales Order Branch ID
  • Sales Order Line Branch ID

 

Hi @Naveen B 

I would like to retrieve the branch ID from the financial settings tab. I believe it’s the sales order branch ID

Userlevel 7
Badge +17

Hi @charlbester34   Please find the sample code to fetch the Sales Order “Branch ID” below.

 

  protected void SOLine_BranchID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
{
if (InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (SOLine)e.Row;

if (row != null)
{
INSetupExt extINSetup = row.GetExtension<INSetupExt>();
int? currentSelectedBranch = Base.Document.Current?.BranchID;

if (extINSetup.UsrAllowBlockin == true && extINSetup.UsrByBranch == true)
{
//TODO
}
else if (extINSetup.UsrAllowBlockin == true && extINSetup.UsrByCompany == true)
{
//TODO
}
}
}

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved