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 :
Finance | Project Operations, Human Resources, ...
Unanswered

How to get current record value in JournalForm

(0) ShareShare
ReportReport
Posted on by 230
Hi Team,
 
I have extend the ProdJournalCheckPost class.
Below code i am using.
[ExtensionOf(classStr(ProdJournalCheckPost))] final class ProdJournalCheckPost_Extension{    public static void main(Args _args)    {               next main(_args);        ProdJournalTable    prodJournalTable;        FormDataSource  prodJournalTable_ds;        Object caller;        MultiSelectionHelper  helper;        JournalForm journalForm;        ProdJournalCheckPost journalCheckPost;              #ISOCountryRegionCodes        try        {                if (_args.dataset() == tableNum(prodJournalTable))                {                    prodJournalTable_ds = _args.callerFormControl().formRun().dataSource();                    caller = _args.caller();                    helper = MultiSelectionHelper::createFromCaller(caller);                    helper.createQueryRanges(prodJournalTable_ds.queryBuildDataSource(), fieldStr(ProdJournalTable, RecId));                    prodJournalTable = helper.getFirst();                    while (prodJournalTable)                    {                        _args.parmEnum(JournalCheckPostType::Check);                        _args.record(prodJournalTable);                                                                     journalForm = JournalForm::fromArgs(_args);                        journalCheckPost = ProdJournalCheckPost::newFromForm(_args,journalForm);                        journalForm.runbaseMainStart();                        //// <GEERU>                        if (SysCountryRegionCode::isLegalEntityInCountryRegion([#isoRU]) && journalCheckPost.mustCheckExistJournalRelease_RU())                        {                            journalCheckPost.checkExistJournalRelease_RU();                        }                        // </GEERU>                        prodJournalTable = helper.getNext();                        journalCheckPost.preRun();                        journalCheckPost.runOperation();                        journalForm.runbaseMainEnd(journalCheckPost,false);                    }                }                          }        catch (Exception::Error)        {            journalForm.runbaseMainEnd(journalCheckPost,true);        }    }}
 
 journalForm = JournalForm::fromArgs(_args);
 
I have pass the current record value in _args but it taking the old record (which is using first time) and i want only current record value it should take.
 
Please let me know how to get the current record value.
 
I have the same question (0)
  • Martin Dráb Profile Picture
    238,740 Most Valuable Professional on at
    Your code is almost impossible to read, so I spent a few minutes formatting it (and I also simplified it a little bit). This should be much better:
    [ExtensionOf(classStr(ProdJournalCheckPost))]
    final class ProdJournalCheckPost_Extension
    {
        public static void main(Args _args)
        {
            next main(_args);
            
            JournalForm journalForm;
            ProdJournalCheckPost journalCheckPost;
    
            #ISOCountryRegionCodes
                      
            try
            {
                if (_args.dataset() != tableNum(prodJournalTable))
                {
                    return;
                }
                
                FormDataSource prodJournalTable_ds = _args.callerFormControl().formRun().dataSource();
                Object caller = _args.caller();
                
                MultiSelectionHelper helper = MultiSelectionHelper::createFromCaller(caller);
                helper.createQueryRanges(prodJournalTable_ds.queryBuildDataSource(), fieldStr(ProdJournalTable, RecId));
                
                ProdJournalTable prodJournalTable = helper.getFirst();
                while (prodJournalTable)
                {
                    _args.parmEnum(JournalCheckPostType::Check);
                    _args.record(prodJournalTable);
    
                    journalForm = JournalForm::fromArgs(_args);
                    journalCheckPost = ProdJournalCheckPost::newFromForm(_args, journalForm);
                    journalForm.runbaseMainStart();
    
                    //// <GEERU>
                    if (SysCountryRegionCode::isLegalEntityInCountryRegion([#isoRU]) && journalCheckPost.mustCheckExistJournalRelease_RU())
                    {
                        journalCheckPost.checkExistJournalRelease_RU();
                    }
                    // </GEERU>
                    
                    prodJournalTable = helper.getNext();
                    journalCheckPost.preRun();
                    journalCheckPost.runOperation();
                    
                    journalForm.runbaseMainEnd(journalCheckPost, false);
                }
            }
            catch (Exception::Error)
            {
                if (journalForm)
                {
                    journalForm.runbaseMainEnd(journalCheckPost, true);
                }
            }    
        }
    }
    Please tell us more about what you mean by "it taking the old record", especially what is "it".
  • CU21091228-0 Profile Picture
    230 on at
    I am try to post Production control -> PickingList.
     
    In form grid i have to select multiple records and post the selected record, due to standard post button multi selection is not possible so i have created new post button with ProdJournalPost menu item.
     
    First i have to do the validation of all the selected records and if there are not any error all the selected record should we post.
     
    In case if i select 3 records from form grid and click on post button.
     
     journalForm = JournalForm::fromArgs(_args);
     in journalForm i am getting only first selected record value, remaining 2 records value i am not getting.
     
    i have pass the prodJournalTable records using  journalForm = JournalForm::fromArgs(_args); 
     
     
  • Martin Dráb Profile Picture
    238,740 Most Valuable Professional on at
    What did you find when you debugged your code, before giving up and asking here? Which parts work and which don't? For example, verify that you're getting all three records from MultiSelectionHelper. If not, all the subsequent code is irrelevant, because it can't work without correct input.
  • CU21091228-0 Profile Picture
    230 on at
    I am getting error  in below code part
    journalCheckPost.runOperation();
    After debugging i found error is coming from below method.
    JournalCheckPost.run()
    In case if i select 3 records. 
     
    For first record 
    prodJournalTable and  journalForm = JournalForm::fromArgs(_args); is match in case there are not any error.
     
    for second record
    prodJournalTable and  journalForm = JournalForm::fromArgs(_args); is not match got the below error.
     
    Journal is not locked by the system.
  • Martin Dráb Profile Picture
    238,740 Most Valuable Professional on at
    There is somewhere a parameter to automatically lock the journal. Use the debugger to find the place throwing the error and then look at the related logic. As you see, knowing just that it's somewhere in the posting (run()) is not detailed enough information. Therefore you need to collect more information to be able to solve the problem.

    Alternatively, you can find the place by finding the label (Dynamics 365 > Find labels) and then opening its references.

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 590 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 349

#3
Diego Mancassola Profile Picture

Diego Mancassola 263

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans