Shared Number Sequence and Update Time Stamp Table

Shared Number Sequence and Update Time Stamp Table

In this article, we have explored the process of creating a custom 'Shared Number Sequence' and updating records in the timestamp table in Dynamics 365 for Finance and Operations.

For generate a number sequence we need to create an EDT String

Add the EDT

Associate the EDT 'NumSeqEDT' with the table field where you intend to establish a number sequence


This is the Field on which we generate the number sequence

Create NumberSeqApplicationModule Class

public class SharedNumberSequence extends NumberSeqApplicationModule
{
    public void loadModule()
    {
        NumberSeqDatatype datatype = NumberSeqDatatype::construct();

        datatype.parmDatatypeId(extendedTypeNum(NumSeqEDT));
        
        datatype.parmWizardIsContinuous(true);
        datatype.parmWizardIsManual(NoYes::No);
        datatype.parmWizardFetchAheadQty(10);
        datatype.parmWizardIsChangeDownAllowed(NoYes::No);
        datatype.parmWizardIsChangeUpAllowed(NoYes::No);
        datatype.parmSortField(1);

        this.create(datatype);
    }

    static numberSequenceReference numRefNumSeqEDT()
    {
        return NumberSeqReference::findReference(extendedTypeNum(NumSeqEDT));
    }

    public NumberSeqModule numberSeqModule()
    {
        return NumberSeqModule::HRM;
    }

    [SubscribesTo(classstr(NumberSeqGlobal),delegatestr(NumberSeqGlobal,buildModulesMapDelegate))]
    static void buildModulesMapSubsciber(Map numberSeqModuleNamesMap)
    {
        NumberSeqGlobal::addModuleToMap(classnum(SharedNumberSequence), numberSeqModuleNamesMap);
    }

}        

After this create a Runnable Class (Job) add the below code

public static void main(Args _args)
    {
        SharedNumberSequence sharedNumberSequence= new SharedNumberSequence();
        sharedNumberSequence.load();
        info("Number sequence loaded for NumSeqEDT");
    }        

Mark this class as "Set As Startup Object"

Navigate to the Organization and Administration -> Number Sequence -> Number Sequence hit Generate Button

Setup the newly created Number Sequence

After completing this step, a new Shared Number Sequence will be generated. Subsequently, proceed to generate numbers from the sequence. In my scenario, this involves updating records in the TimeStamp table.

select forupdate validtimestate(startDateValue,endDateValue) * from  hcmEmployment
                    where hcmEmployment.Worker == recId;

                ttsbegin;

                hcmemployment.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);
                numSeq = NumberSeq::newGetNum(SharedNumberSequence ::numRefNumSeqEDT());
                newnum = numSeq.num();
                hcmemployment.NumberSeq= newnum;
                hcmemployment.update();

                ttscommit;        

This constitutes the primary logic wherein the records of the timestamp table are updated, and the generate the new number from the number sequence.


要查看或添加评论,请登录

Muhammad Farzam的更多文章

  • Recurring Integration

    Recurring Integration

    In this blog, I will explain how to perform recurring integrations using Power Automate. Specifically, I will detail an…

    1 条评论

社区洞察

其他会员也浏览了