web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Syslastvalue in dialogs

(0) ShareShare
ReportReport
Posted on by
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

I have the same question (0)
  • Liviu Stoica Profile Picture
    160 on at

    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

     

  • Verified answer
    Community Member Profile Picture
    on at

    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

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Andrew Jones a1x Profile Picture

Andrew Jones a1x 2

#3
GL-01081504-0 Profile Picture

GL-01081504-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans