Skip to main content
Solved

How to add alternate ID specifically for 'OEM Part Number' description

  • May 4, 2026
  • 5 replies
  • 44 views

Forum|alt.badge.img

When doing stock take, I want to be able to see stock item’s Alternate ID, specifically for ‘OEM Part Numbers’ - I want the Alternate ID on Prepare Physical Count review, Physical Inventory Count and Physical Inventory Review screen. I note they are not a generic inquiry screens and thought this is possible via customizations?

 

Best answer by Naveen Boga

@MarkD  Sure. Please follow the below steps.

  1. Extend the DAC - PIPreliminaryResult and introduce a new custom field i.e. UsrAlternateID
  2. Extend the Graph - PIGenerator and write the below logic to populate the UsrAlternateID from the Stock Items → Cross Reference tab

 

DAC Extension field:

 #region UsrAlternateID
[PXString(50, IsUnicode = true)]
[PXUIField(DisplayName = "Alternate ID", Enabled = false)]
public virtual string UsrAlternateID { get; set; }
public abstract class usrAlternateID :
PX.Data.BQL.BqlString.Field<usrAlternateID> { }
#endregion

 Graph Logic add in the FieldSelecting event to populate the UsrAlternate ID. If required, please make the changes to the code.

 public static string GetOEMAlternateID(PXGraph graph, int? inventoryID)
{
if (inventoryID == null) return null;

// First try — Global type with OEM Part Nbr description
INItemXRef xref = SelectFrom<INItemXRef>
.Where<INItemXRef.inventoryID.IsEqual<@P.AsInt>
.And<INItemXRef.alternateType.IsEqual<INAlternateType.global>>
.And<INItemXRef.descr.IsEqual<@P.AsString>>>
.View.Select(graph, inventoryID, "OEM Part Nbr");

if (xref != null)
return xref.AlternateID;

// Second try — Global type, any description (fallback)
INItemXRef xrefGlobal = SelectFrom<INItemXRef>
.Where<INItemXRef.inventoryID.IsEqual<@P.AsInt>
.And<INItemXRef.alternateType.IsEqual<INAlternateType.global>>>
.View.Select(graph, inventoryID);

return xrefGlobal?.AlternateID;
}

 

5 replies

Naveen Boga
Captain II
Forum|alt.badge.img+20
  • Captain II
  • May 4, 2026

Yes ​@MarkD  This is possible via customization.


Forum|alt.badge.img
  • Author
  • Varsity I
  • May 4, 2026

Thanks ​@Naveen Boga - Can you please guide me with the steps on how this is done via customization? Might need a code as well


Naveen Boga
Captain II
Forum|alt.badge.img+20
  • Captain II
  • Answer
  • May 4, 2026

@MarkD  Sure. Please follow the below steps.

  1. Extend the DAC - PIPreliminaryResult and introduce a new custom field i.e. UsrAlternateID
  2. Extend the Graph - PIGenerator and write the below logic to populate the UsrAlternateID from the Stock Items → Cross Reference tab

 

DAC Extension field:

 #region UsrAlternateID
[PXString(50, IsUnicode = true)]
[PXUIField(DisplayName = "Alternate ID", Enabled = false)]
public virtual string UsrAlternateID { get; set; }
public abstract class usrAlternateID :
PX.Data.BQL.BqlString.Field<usrAlternateID> { }
#endregion

 Graph Logic add in the FieldSelecting event to populate the UsrAlternate ID. If required, please make the changes to the code.

 public static string GetOEMAlternateID(PXGraph graph, int? inventoryID)
{
if (inventoryID == null) return null;

// First try — Global type with OEM Part Nbr description
INItemXRef xref = SelectFrom<INItemXRef>
.Where<INItemXRef.inventoryID.IsEqual<@P.AsInt>
.And<INItemXRef.alternateType.IsEqual<INAlternateType.global>>
.And<INItemXRef.descr.IsEqual<@P.AsString>>>
.View.Select(graph, inventoryID, "OEM Part Nbr");

if (xref != null)
return xref.AlternateID;

// Second try — Global type, any description (fallback)
INItemXRef xrefGlobal = SelectFrom<INItemXRef>
.Where<INItemXRef.inventoryID.IsEqual<@P.AsInt>
.And<INItemXRef.alternateType.IsEqual<INAlternateType.global>>>
.View.Select(graph, inventoryID);

return xrefGlobal?.AlternateID;
}

 


Forum|alt.badge.img
  • Author
  • Varsity I
  • May 5, 2026

Champion! ​@Naveen Boga - I managed to pull it up using those steps and modify your code based on what I need. I will mark your answer as ‘Best Answer’

Below is my code:

using PX.Data;
using PX.Objects.IN;

#region UsrAlternateID
public class PIGeneratorExt : PXGraphExtension<PIGenerator>
{
    public static string GetOEMAlternateID(PXGraph graph, int? inventoryID)
    {
        if (inventoryID == null) return null;

        // Only look for Global type with OEM Part Nbr description
        PXResult<INItemXRef> xref = PXSelect<INItemXRef,
            Where<INItemXRef.inventoryID, Equal<Required<INItemXRef.inventoryID>>,
            And<INItemXRef.alternateType, Equal<INAlternateType.global>,
            And<INItemXRef.descr, Equal<Required<INItemXRef.descr>>>>>>.Select(graph, inventoryID, "OEM Part Nbr");

        if (xref != null)
            return ((INItemXRef)xref).AlternateID;

        // If not found, return null (no fallback)
        return null;
    }

    protected virtual void PIPreliminaryResult_UsrAlternateID_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
    {
        if (e.Row is PIPreliminaryResult row)
        {
            e.ReturnValue = GetOEMAlternateID(this.Base, row.InventoryID);
        }
    }
}
#endregion

 

 


Naveen Boga
Captain II
Forum|alt.badge.img+20
  • Captain II
  • May 5, 2026

@MarkD  Awesome!! You modified the code and it worked. Thanks for sharing the update.