Implement Numbering Sequence for Customized Field

In this article, I would like to cover how to add a numbering sequence to the customized field in the custom screens.

Numbering Sequences are useful to generate a unique number or ID each time a user creates a document. I have created a new customized screen i.e. Deck Setup with DeckNbr as a auto-numbering field. Please find the details below.

Example

[PXCacheName("Deck Setup")]
    public class KNDeckSetup : IBqlTable
    {
        #region DeckNbr
        [PXDBString(15, IsKey = true, IsUnicode = true, InputMask = "")]
        [PXUIField(DisplayName = "Deck ID", Visibility = PXUIVisibility.SelectorVisible)]
        [PXDefault(PersistingCheck = PXPersistingCheck.NullOrBlank)]
        [PXSelector(typeof(KNDeckSetup.deckNbr), typeof(KNDeckSetup.deckNbr))]
        [AutoNumber(typeof(KNSOSetupExt.usrDeckNumberingID), typeof(KNDeckSetup.createdDateTime))]

        public virtual string DeckNbr { get; set; }
        public abstract class deckNbr : BqlString.Field<deckNbr> { }
        #endregion

      // Remaining DAC fields Deck Name, Username, and Password and etc.,
      }

Deck Setup Graph Code

public class DeckSetup : PXGraph<DeckSetup>
    {
        #region View
        public PXSelect<KNDeckSetup> KNDeckSetup;
        public PXSave<KNDeckSetup> Save;
        public PXCancel<KNDeckSetup> Cancel;
        #endregion
 

        public PXAction<KNDeckSetup> TestConnection;
        [PXButton]
        [PXUIField(DisplayName = "TEST CONNECTION", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Enabled = false)]
        protected virtual IEnumerable testConnection(PXAdapter adapter)
        {
            // logic here
            return adapter.Get();
        }
    }

Sales Order Preference screen customization

Introduced a new custom field i.e., Deck Numbering Sequence in the Sales Order Preferences screen. The numbering sequence is to be used to assign IDs to Deck when a new Deck is created by using the Deck Setup screen.

public class KNSOSetupExt : PXCacheExtension<SOSetup>
    {
        #region UsrDeckNumberingID
        [PXDBString(15, IsUnicode = true, InputMask = "")]
        [PXUIField(DisplayName = "Deck Numbering Sequence", Required = true)]
        [PXSelector(typeof(Numbering.numberingID), DescriptionField = typeof(Numbering.descr))]
        public virtual string UsrDeckNumberingID { get; set; }
        public abstract class usrDeckNumberingID : BqlString.Field<usrDeckNumberingID> { }
        #endregion
    }

Screenshots

1 Reply to “Implement Numbering Sequence for Customized Field”

  1. Remove Extension DAC at Runtime

    This is our existing implementation that used work in 2019 version, basically the below piece of code removes an Ext Dac at runtime from the sorted list. We are planning to use the same implementation in 2022 R1 version, only change here is ActivateOnApplicationStart is obsolete in Autofac. For some reason the implementation is not working anymore, any thoughts on how this can be achieved or any better suggestions to implement the same?

    namespace MyLib
    {
    public class ServiceRegistration : Module

    {
    protected override void Load(ContainerBuilder builder)
    {

    builder.ActivateOnApplicationStart(); // 2019 version

    /*builder.RegisterType(typeof(ExtensionSorting)) 2022 r1
    .PreserveExistingDefaults()
    .InstancePerDependency();*/
    }
    private class ExtensionSorting
    {
    private List mySort(List list)
    {
    if (list.Contains(typeof(CRCaseExt)))
    {
    list.Remove(typeof(CRCaseExt));
    }
    list.Sort((t1, t2) => { return t1.FullName.CompareTo(t2.FullName); });
    return list;
    }

    public ExtensionSorting()
    {
    PXBuildManager.SortExtensions += (list) => mySort(list);
    }
    }
    }
    }
    }

Leave a Reply

Your email address will not be published. Required fields are marked *