Skip to main content
Question

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

  • July 20, 2023
  • 6 replies
  • 148 views

Forum|alt.badge.img

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

aaghaei
Captain II
Forum|alt.badge.img+10
  • Captain II
  • July 20, 2023

In your Select Change the SiteID to SiteCD


Forum|alt.badge.img
  • Author
  • Varsity I
  • July 21, 2023

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;
}

 


aaghaei
Captain II
Forum|alt.badge.img+10
  • Captain II
  • July 21, 2023

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


darylbowman
Captain II
Forum|alt.badge.img+15

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;

 


dcomerford
Captain II
Forum|alt.badge.img+15
  • Captain II
  • July 26, 2023

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;
          }


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • August 22, 2023

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