Skip to main content
Answer

PXSelector get value from the lookup other than the key

  • June 20, 2023
  • 3 replies
  • 383 views

All:

I have a grid with a PXSelector in one of the columns.  When I pick an item from the selector, the selector has 5 columns in it.  I want to get the value of one of those columns that is not the value that will be stored in the field when the value is selected and then store it in an additional field in the grid. 

In other words, I pick a value from a selector, and the key value goes into the field with the PXSelector and the value from Column 3 of the selector goes into a different field in the grid.

Is this possible?

Thanks,

Ryan

Best answer by Josiah Lisle

 

aaghaei, do you have a code example of this?  In my research in the developer documentation, I’m not seeing how this is possible.

If I am understanding the question, here is one way you might go about this, assuming SOLine is the grid you are working with, InventoryID is the selector field, and you want to copy the fieldToUpdate into the CorrespondingField for the SOLine.

 

using PX.Data;
using PX.Objects.SO;
using PX.Objects.IN;
namespace SomeNameSpace
{
    // Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
    public class SOOrderEntryExt2 : PXGraphExtension<SOOrderEntry>
    {
        public PXSelect<SOLine> Lines;
        protected void SOLine_InventoryID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e, PXFieldUpdated baseMethod)
        {
            baseMethod?.Invoke(sender, e);
            SOLine line = (SOLine)e.Row;
            if (line == null) return;

            InventoryItem item = PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>.Select(Base, line.InventoryID);

            if (item != null)
            {
                Lines.SetValueExt<SOLine.fieldToUpdate>(line, item.CorrespondingField);
            }
        }
    }
}

3 replies

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

I assume you by customization so yes. You will need to add an unbounded field and to the DAC extension of the grid then in FieldSelecting event of the selector you can get any column you wish whether is amongst the selector columns or not.

In the FieldUpdated of the selector also you might need to refresh the display column desired value


  • Author
  • Freshman I
  • June 21, 2023

I assume you by customization so yes. You will need to add an unbounded field and to the DAC extension of the grid then in FieldSelecting event of the selector you can get any column you wish whether is amongst the selector columns or not.

In the FieldUpdated of the selector also you might need to refresh the display column desired value

aaghaei, do you have a code example of this?  In my research in the developer documentation, I’m not seeing how this is possible.


Forum|alt.badge.img+1
  • Jr Varsity I
  • Answer
  • June 6, 2024

 

aaghaei, do you have a code example of this?  In my research in the developer documentation, I’m not seeing how this is possible.

If I am understanding the question, here is one way you might go about this, assuming SOLine is the grid you are working with, InventoryID is the selector field, and you want to copy the fieldToUpdate into the CorrespondingField for the SOLine.

 

using PX.Data;
using PX.Objects.SO;
using PX.Objects.IN;
namespace SomeNameSpace
{
    // Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
    public class SOOrderEntryExt2 : PXGraphExtension<SOOrderEntry>
    {
        public PXSelect<SOLine> Lines;
        protected void SOLine_InventoryID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e, PXFieldUpdated baseMethod)
        {
            baseMethod?.Invoke(sender, e);
            SOLine line = (SOLine)e.Row;
            if (line == null) return;

            InventoryItem item = PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>.Select(Base, line.InventoryID);

            if (item != null)
            {
                Lines.SetValueExt<SOLine.fieldToUpdate>(line, item.CorrespondingField);
            }
        }
    }
}