Skip to main content
Answer

Cross reference - Alternate type

  • November 25, 2020
  • 5 replies
  • 976 views

pandachan48
Jr Varsity II
Forum|alt.badge.img

Can we rename the Alternate Type
e.g “Global” I want to rename to “ABC”

 

Best answer by Naveen Boga

Hi @pandachan48 ,

 

Understood. To modify the dropdown item values, please use the code like below.

 

public class InventoryItemMaintAMIExt : PXGraphExtension<InventoryItemMaint>
    {
[PXMergeAttributes(Method = MergeMethod.Append)] 
        [PXRemoveBaseAttribute(typeof(INAlternateType))]
        [INAlternateTypeExt.List()]
        protected virtual void INItemXRef_AlternateType_CacheAttached(PXCache sender) { }

}

 

 public class INAlternateTypeExt
    {
        public class List : PXStringListAttribute
        {
            public List() : base(
                new[]
            {
                    Pair(CPN, PX.Objects.IN.Messages.CPN),
                    Pair(VPN, PX.Objects.IN.Messages.VPN),
                    Pair(Global, "ABCD"),
                    Pair(Barcode, PX.Objects.IN.Messages.Barcode),
                })
            { }
        }

        public const string CPN = "0CPN";
        public const string VPN = "0VPN";
        public const string MFPN = "MFPN";
        public const string Global = "GLBL";
        public const string Substitute = "SBST";
        public const string Obsolete = "OBSL";
        public const string SKU = "SKU";
        public const string UPC = "UPC";
        public const string EAN = "EAN";
        public const string ISBN = "ISBN";
        public const string GTIN = "GTIN";
        public const string Barcode = "BAR";

        public class cPN : PX.Data.BQL.BqlString.Constant<cPN>
        {
            public cPN() : base(CPN) {; }
        }

        public class vPN : PX.Data.BQL.BqlString.Constant<vPN>
        {
            public vPN() : base(VPN) {; }
        }

        public class global : PX.Data.BQL.BqlString.Constant<global>
        {
            public global() : base(Global) {; }
        }

        public class obsolete : PX.Data.BQL.BqlString.Constant<obsolete>
        {
            public obsolete() : base(Obsolete) {; }
        }
        public class barcode : PX.Data.BQL.BqlString.Constant<barcode>
        {
            public barcode() : base(Barcode) {; }
        }
        public static string ConvertFromPrimary(INPrimaryAlternateType aPrimaryType)
        {
            return aPrimaryType == INPrimaryAlternateType.VPN ? INAlternateType.VPN : INAlternateType.CPN;
        }

        public static INPrimaryAlternateType? ConvertToPrimary(string aAlternateType)
        {
            INPrimaryAlternateType? result = null;
            switch (aAlternateType)
            {
                case INAlternateType.VPN:
                    result = INPrimaryAlternateType.VPN; break;
                case INAlternateType.CPN:
                    result = INPrimaryAlternateType.CPN; break;
            }
            return result;
        }

    }

 

5 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • November 25, 2020

Hi @pandachan48,

 

We can have below code in InventoryItemMaint Extension graph to rename the UI field name by using cache_attached event.

        [PXMergeAttributes(Method = MergeMethod.Append)]
        [PXCustomizeBaseAttribute(typeof(PXUIFieldAttribute), nameof(PXUIFieldAttribute.DisplayName), "ABCD")]
        protected virtual void INItemXRef_AlternateType_CacheAttached(PXCache sender) { }
 

Please find the screenshot for the reference.

 


pandachan48
Jr Varsity II
Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • November 25, 2020

thank you for your reply 
but I mean I need to rename “Global” to ABCD

 

 


pandachan48
Jr Varsity II
Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • November 25, 2020

I found it how to rename the name (Translation Dictionaries), but after I changed, I cannot change back or change to another
could some one advice how to change back or rename to another? 

thank you!!

 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • Answer
  • November 25, 2020

Hi @pandachan48 ,

 

Understood. To modify the dropdown item values, please use the code like below.

 

public class InventoryItemMaintAMIExt : PXGraphExtension<InventoryItemMaint>
    {
[PXMergeAttributes(Method = MergeMethod.Append)] 
        [PXRemoveBaseAttribute(typeof(INAlternateType))]
        [INAlternateTypeExt.List()]
        protected virtual void INItemXRef_AlternateType_CacheAttached(PXCache sender) { }

}

 

 public class INAlternateTypeExt
    {
        public class List : PXStringListAttribute
        {
            public List() : base(
                new[]
            {
                    Pair(CPN, PX.Objects.IN.Messages.CPN),
                    Pair(VPN, PX.Objects.IN.Messages.VPN),
                    Pair(Global, "ABCD"),
                    Pair(Barcode, PX.Objects.IN.Messages.Barcode),
                })
            { }
        }

        public const string CPN = "0CPN";
        public const string VPN = "0VPN";
        public const string MFPN = "MFPN";
        public const string Global = "GLBL";
        public const string Substitute = "SBST";
        public const string Obsolete = "OBSL";
        public const string SKU = "SKU";
        public const string UPC = "UPC";
        public const string EAN = "EAN";
        public const string ISBN = "ISBN";
        public const string GTIN = "GTIN";
        public const string Barcode = "BAR";

        public class cPN : PX.Data.BQL.BqlString.Constant<cPN>
        {
            public cPN() : base(CPN) {; }
        }

        public class vPN : PX.Data.BQL.BqlString.Constant<vPN>
        {
            public vPN() : base(VPN) {; }
        }

        public class global : PX.Data.BQL.BqlString.Constant<global>
        {
            public global() : base(Global) {; }
        }

        public class obsolete : PX.Data.BQL.BqlString.Constant<obsolete>
        {
            public obsolete() : base(Obsolete) {; }
        }
        public class barcode : PX.Data.BQL.BqlString.Constant<barcode>
        {
            public barcode() : base(Barcode) {; }
        }
        public static string ConvertFromPrimary(INPrimaryAlternateType aPrimaryType)
        {
            return aPrimaryType == INPrimaryAlternateType.VPN ? INAlternateType.VPN : INAlternateType.CPN;
        }

        public static INPrimaryAlternateType? ConvertToPrimary(string aAlternateType)
        {
            INPrimaryAlternateType? result = null;
            switch (aAlternateType)
            {
                case INAlternateType.VPN:
                    result = INPrimaryAlternateType.VPN; break;
                case INAlternateType.CPN:
                    result = INPrimaryAlternateType.CPN; break;
            }
            return result;
        }

    }

 


Forum|alt.badge.img
  • Jr Varsity III
  • September 9, 2022

I noticed that GTIN is in the code already. How do I enable that value? Our client needs to store the barcode separately from the GTIN.

 

Thank you.