Skip to main content
Question

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

  • Jul 20, 2023 4:25 AM UTC
  • 6 replies
  • 186 views
  • Translate All

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+11
  • Captain II
  • Jul 20, 2023 4:31 AM UTC

In your Select Change the SiteID to SiteCD

Translate

Forum|alt.badge.img
  • Author
  • Varsity I
  • Jul 21, 2023 7:28 AM UTC

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

 

Translate

aaghaei
Captain II
Forum|alt.badge.img+11
  • Captain II
  • Jul 21, 2023 7:33 AM UTC

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

Translate

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

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;

 

Translate

dcomerford
Captain II
Forum|alt.badge.img+16
  • Captain II
  • Jul 26, 2023 4:26 PM UTC

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

Translate

Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • Aug 22, 2023 9:02 PM UTC

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

Translate