Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

How to save the field content for later? ax2012 x++

(0) ShareShare
ReportReport
Posted on by 15

I create a job in x ++. I would like the dialogfields inside the dialog to remember what the user entered for later (until the next Job launch)
How to do it?
Does Ax2012 have mechanisms to remember user variables?
Or do I need to write values to files on disk, or to the windows registry?

Best regards
Tom

  • Tom Fi Profile Picture
    15 on at
    RE: How to save the field content for later? ax2012 x++

    Good point of view. I will think about it next time

    This code is for the IT department only. It has historically been a practice in the IT department to use Jobs to automate activities. It has remained so far

    Thank you for replies :)

  • nmaenpaa Profile Picture
    101,158 Moderator on at
    RE: How to save the field content for later? ax2012 x++

    Yes, it only works in a class because you need to extend RunBase. Why are you using a job for something that is executed often? You should develop a class, link it to a menu item, menu, security and so on. Jobs are not intended for implementing actual business operations.

  • Tom Fi Profile Picture
    15 on at
    RE: How to save the field content for later? ax2012 x++

    I didn't understand this part and missed it.
    Now I understand a little, but does it all only work inside classes?

    [SOLVED

    I made progress and found another solution using xSysLastValue.

    I present a solution for other interested people:

        DialogRunbase           dlg;
        DialogField             txtDim, lstWorker;
        container               conValues;
        
        dlg = new Dialog("Title");
        txtDim = dlg.addField(extendedTypeStr(Comments_JP), "Parameters");
        lstWorker = dlg.addField(extendedTypeStr(HcmWorkerRecId), "Select worker");
    
        conValues = xSysLastValue::getValue(curExt(), curUserId(), UtilElementType::Job, "SaveLastValue");
    
        if (conValues != conNull()) {
            txtDim.value(conPeek(conValues, 1));
            lstWorker.value(conPeek(conValues, 2));
        }
        
        if (dlg.run()) {
            conValues = conNull();
            conValues  = txtDim.value();
            conValues  = lstWorker.value();
            xSysLastValue::putValue(conValues, curExt(), curUserId(), UtilElementType::Job, "SaveLastValue");
        }
    

    It works ok

  • nmaenpaa Profile Picture
    101,158 Moderator on at
    RE: How to save the field content for later? ax2012 x++

    Did you find the tutorial class? Pay attention to the CurrentList macro in class declaration (define list of variables to be stored), as well as pack (saving values) and unpack (fetching old values) methods.

  • Tom Fi Profile Picture
    15 on at
    RE: How to save the field content for later? ax2012 x++

        DialogRunbase           dlg;
        DialogField             txtDim, lstWorker;
        
        dlg = new Dialog("Title");
        txtDim = dlg.addField(extendedTypeStr(Comments_JP), "Parameters");
        lstWorker = dlg.addField(extendedTypeStr(HcmWorkerRecId), "Select worker");
    
        dlg.run();

    I made DialogRunbase like this.
    It doesn't remember the values the next time it is started
    What is missing?

  • nmaenpaa Profile Picture
    101,158 Moderator on at
    RE: How to save the field content for later? ax2012 x++

    You should use RunBase or SysOperation framework, then the last values are stored automatically.

    Check class Tutorial_RunBaseBatch.

  • Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: How to save the field content for later? ax2012 x++

    Hi Tom,

    Assuming you are talking about X++ job, I don't think you can save the last values.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,161 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,942 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans