Solved

Conditionally set a Default value from a selector

  • 9 January 2023
  • 6 replies
  • 246 views

Userlevel 4
Badge

Hi everyone,

Need to set a default warehouse for specific types of order in the form below.

Kindly assist

 

 

icon

Best answer by jinin 13 January 2023, 08:45

View original

6 replies

Userlevel 4
Badge +1

Hi @development93,

You can create/modify the Warehouse selector like the below:

[PXSelector(typeof(Search<APDiscount.discountID, 
                    Where<APDiscount.bAccountID, 
                    Equal<Current<VendorDiscountSequence.vendorID>>>>))]

 

Note: Change DAC and Field Names as per your requirement.

 

 

Hope this may help you!

Moulali Shaik.

Userlevel 7
Badge +11

Hi @development93 ,

You can also write the logic in the Order Type Field updated event, based on the order type you can assign the Warehouse for the field.

Example,

  protected virtual void SOOrder_OrderNbr_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            if (e.Row == null) return;
            SOOrder row = (SOOrder)e.Row;

            row.SiteID = warehouseID; // Assign the Warehouse for the field
        }

Userlevel 4
Badge

Thank you for all your responses

But am stack a bit. New to acumatica.

 

 

To be more specific of what I need. When I select DS order type the warehouse FGS should be the default one or it should populate itself upon choosing this specific order type.

 

All responses will be highly appreciated

Thank you

 

Userlevel 4
Badge +1

Hi @development93,

In that case, you need to follow as jinin suggested.

For Example:

protected void _(Events.FieldUpdated<DACNAME, DACNAME.inventoryID> e)
        {
            var row = (DACNAME)e.Row;
            if (row == null) return;
            InventoryItem inventory = SelectFrom<InventoryItem>
                                      .Where<InventoryItem.inventoryID.IsEqual<@P.AsInt>>
                                      .View.Select(this,row.InventoryID);
            if(inventory != null)
            {
                row.Description = inventory.Descr;
            }
        }

 

Note: Make the field Layout property commitChanges = true.

Hope this helps you!

 

Thanks,

Moulali Shaik.

Userlevel 4
Badge

Hi @development93 ,

You can also write the logic in the Order Type Field updated event, based on the order type you can assign the Warehouse for the field.

Example,

  protected virtual void SOOrder_OrderNbr_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            if (e.Row == null) return;
            SOOrder row = (SOOrder)e.Row;

            row.SiteID = warehouseID; // Assign the Warehouse for the field
        }

 

 

 

Note: When one choose a value for the Inventory ID the warehouse field is updated.

So I decided to to go along with @jinin approach such that when the Inventory Id is not null the warehouse filed should be updated with the value I want.

But I got the following error

Maybe because the field is set to accept Integer values;

 

How should I go along with this?

Kindly help.

Userlevel 7
Badge +11

Hi @development93 

you should write the BQL to get the SiteID from the INSite table.

Example,

  protected virtual void SOOrder_OrderNbr_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
{
if (e.Row == null) return;
SOOrder row = (SOOrder)e.Row;

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

row.SiteID = site?.siteID;
}








 

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