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

Announcements

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans