Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Unanswered

How to get current record value in JournalForm

(0) ShareShare
ReportReport
Posted on by 171
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.
 
  • Martin Dráb Profile Picture
    Martin Dráb 230,853 Most Valuable Professional on at
    How to get current record value in JournalForm
    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.
  • CU21091228-0 Profile Picture
    CU21091228-0 171 on at
    How to get current record value in JournalForm
    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
    Martin Dráb 230,853 Most Valuable Professional on at
    How to get current record value in JournalForm
    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
    CU21091228-0 171 on at
    How to get current record value in JournalForm in D365FO
    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
    Martin Dráb 230,853 Most Valuable Professional on at
    How to get current record value in JournalForm in D365FO
    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".

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,996 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,853 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans