Question

Set default value for fields in Inventory Lookup dialog box in Sales Orders screen

  • 20 July 2023
  • 6 replies
  • 91 views

Userlevel 4
Badge

Hi,

 

In the Sales Orders screen, after clicking ‘Add Items’, as shown in the second image below, a client is wanting the Warehouse field to be set to ‘MAIN’ in the dialog box shown in the third image below.

 

The code I currently have set up doesn’t seem to work. I am using the FieldDefaulting event but would I need to combine this event with another one, like RowSelected, to pass the value through?

 

Let me know if I can provide any other information.

 

Kind regards,

Andrew

 

protected void SOSiteStatusFilter_SiteID_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e)
{
if (e.Row == null) return;

SOSiteStatusFilter row = (SOSiteStatusFilter)e.Row;

INSite site = PXSelectReadonly<INSite, Where<INSite.siteID, Equal<Required<INSite.siteID>>>>.Select(Base, "MAIN");


row.SiteID = site?.SiteID;
}

 


6 replies

Userlevel 7
Badge +8

In your Select Change the SiteID to SiteCD

Userlevel 4
Badge

Hi Reza,

 

Thanks for your response. This is how my code looks now, but unfortunately it still doesn’t work. Is it possible that this grid has some code in the business logic that is overriding my code?

 

Kind regards,

Andrew

 

protected void SOSiteStatusFilter_SiteID_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e)
{
if (e.Row == null) return;

SOSiteStatusFilter row = (SOSiteStatusFilter)e.Row;
INSite site = PXSelectReadonly<INSite, Where<INSite.siteCD, Equal<Required<INSite.siteCD>>>>.Select(Base, "MAIN");


row.SiteID = site?.SiteID;
}

 

Userlevel 7
Badge +8

When you trace, does “site” variable have value or is null?

Badge +11

Since this is a field defaulting event, you want to use

e.NewValue = site?.SiteID;
e.Cancel = true;

 

Or perhaps better, only assign a new value if the new value isn't null

if (site?.SiteID is null) return;

e.NewValue = site?.SiteID;
e.Cancel = true;

 

Userlevel 7
Badge +12

I have done something similiar on the PO line but i had to use a BQL data constant to hold the Code in my case ‘DropShip’

public class constantA : PX.Data.BQL.BqlString.Constant<constantA>
  {
  public constantA() : base("DROPSHIP") { }
  }

 

Then used this in the PXSelect to get the SiteID 

    INSite site = PXSelect<INSite, Where<INSite.siteCD, Equal<constantA>>>.Select(Base, row.SiteID);
      if (site !=null)
        {
    row.SiteID = site.SiteID;
          }

Userlevel 7
Badge

Hi @AndrewA were you able to find a solution? Thank you!

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