@MarkD Sure. Please follow the below steps.
- Extend the DAC - PIPreliminaryResult and introduce a new custom field i.e. UsrAlternateID
- 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;
}