Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Unanswered

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

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
    Tom Fi 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
    nmaenpaa 101,148 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
    Tom Fi 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
    nmaenpaa 101,148 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
    Tom Fi 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
    nmaenpaa 101,148 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
    Gunjan Bhattachayya 35,417 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.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,459 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,783 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans