Skip to main content
Solved

Filter warehouse by Branch/Company

  • September 21, 2021
  • 3 replies
  • 275 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.

Best answer by Naveen Boga

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

 

View original
Did this topic help you find an answer to your question?

3 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3404 replies
  • Answer
  • September 21, 2021

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

 


  • Author
  • Freshman I
  • 6 replies
  • September 21, 2021

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


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3404 replies
  • September 21, 2021

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings