Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Syslastvalue in dialogs

(0) ShareShare
ReportReport
Posted on by Microsoft Employee
Hi If I write code like this, dialog = new Dialog("Test"); diaAddressType = dialog.addField(typeid(AddressType)); if (dialog.run()) { addressType = diaAddressType.value(); } Would it be possible to use SysLasyValue or something similar to store the value of addressType for the current user, and set that value as a default value in diaAddressType the next time the method is being run? /Jonas

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    Re: Syslastvalue in dialogs

    Thanks. In my case the dialog was, however, opened from a Form. But I found the following article just now:

    axhelper.blogspot.com/.../storing-last-form-values.html

    that explains how to add the pack/unpack functionality to a form.

    /Jonas

  • Liviu Stoica Profile Picture
    Liviu Stoica 160 on at
    Re: Syslastvalue in dialogs

    Hi Jonas,

    I hope that  the following exemple is relevant  for you:

     


    --------------------------------------------------------------------------------------------------------------------------

    static void main(Args args)

    {

        Class1    class1;

    ;

        class1  = new Class1();

        if (class1.prompt())

            class1.run();

    }

    ---------------------------------------------------------------------------------------------------------------------
    class class1 extends RunBaseBatch
    {
        DialogRunbase                       dialog;
        // Packed variables
        TaxAddressType     addressType;
        // Dialog fields
        DialogField     dialogAddressType ;
        #define.CurrentVersion(6)
        #localmacro.CurrentList
            addressType
        #endmacro
    }
    --------------------------------------------------------------------------------------------------------------------------
    public TaxAddressType parmAddressType(TaxAddressType _addressType = addressType)
    {
        ;
        addressType = _addressType;
        return addressType;
    }
    ----------------------------------------------------------------------------------------------------------------------
    public Object dialog()
    {
    ;
        dialog = new dialogRunBase('test',this);
        xSysLastValue::getLast(this);
        dialogAddressType  = dialog.addField(typeid(taxAddressType));
        dialogAddressType.value(this.parmAddressType());
        return dialog;
    }
    -------------------------------------------------------------------------------------------------
    public boolean getFromDialog()
    {
        boolean                 ret;
        ;
        ret                     = super();
        addressType   = dialogAddressType.value();
        return ret;
    }
    ----------------------------------------------------------------------------------------------------
    public container pack()
    {
        ;
        return [#CurrentVersion, #CurrentList];
    }
    ------------------------------------------------------------------------------------------------------
    public boolean unpack(container packedClass)
    {
        Integer     version         = RunBase::getVersion(packedClass);
        ;
        switch (version)
        {
            case #CurrentVersion :
                [version, #CurrentList] = packedClass;
                break;
            default :
                return false;
        }
        return true;
    }
    ---------------------------------------------------------------------------------------------------------------
    // Here goes a description of the class
    static ClassDescription description()
    {
        return "class1";
    }
    =================================================================
    public void run()
    {
        #OCCRetryCount
        try
        {
            ttsbegin;
            info(strfmt('%1',addressType));
            xSysLastValue::saveLast(this);
            ttscommit;
        }
        catch (Exception::Deadlock)
        {
            retry;
        }
        catch (Exception::UpdateConflict)
        {
            if (appl.ttsLevel() == 0)
            {
                if (xSession::currentRetryCount() >= #RetryNum)
                {
                    throw Exception::UpdateConflictNotRecovered;
                }
                else
                {
                    retry;
                }
            }
            else
            {
                throw Exception::UpdateConflict;
            }
        }
    }
    ================================================================
    Best regards,
    Liviu Stoica
    Dynamics AX Developer

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,642 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,371 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans