Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / How to Extend InventJo...
Finance forum
Suggested answer

How to Extend InventJournalCheckPost class

Posted on by 1,867
Dear All,
 
I'm trying to put some logic before transfer journal posting. I'm unable find proper way to use newPostJournal(). Could you please check below and advice right way to from below code.
 
[ExtensionOf(classStr(InventJournalCheckPost))]
final class InventJournalCheckPost_EAway_Extension
{
    public static JournalCheckPost newPostJournal(InventJournalTable _inventJournalTable)
    {
         next newPostJournal(_inventJournalTable) ;
   }
}
  • Faqruddin Profile Picture
    Faqruddin 1,867 on at
    How to Extend InventJournalCheckPost class
    checkJournal() method  for validating the journal. I don't want to validate instead if user click on post button I need to trigger below logic. I move my code to postJournal() method of JournalCheckPost class and below custom logic is not executing. Please advice. Correct me If my execution is wrong.
    [ExtensionOf(classStr(JournalCheckPost))]
    final class JournalCheckPost_VanAway_Extension
    {
        protected void postJournal(JournalTransList _journalTransList)
        {
            int switchValue = 0;
            str 50 journalNum;
            NoYes vanaway;
            Dialog dialog;
            dialogGroup dialogGroup;
            dialogField dialogField;
            DAWLoadRequest _dawLoadRequest;
            InventJournalTable journalTable;
            JournalCheckPost inventJournalCheckPost;
         
            dialog = new Dialog("Load Request OTP");
    
            dialogGroup = dialog.addGroup("Please Enter OTP");
    
            dialogField = dialog.addField(extendedTypeStr(OTP));
    
            
              journalNum  = _journalTransList.journalTableData().journalTable().JournalId;
            vanaway = InventJournalTable::find(journalNum).VanAway;
            select *from _dawLoadRequest   where _dawLoadRequest.JournalNum == journalNum;
    
            info(strFmt("JournNum %1", journalNum));
    
            if(_dawLoadRequest.JournalNum)
            {
    
                if(vanaway == NoYes::Yes )
                {
                    if (dialog.run())
    
                    {
                        if(_dawLoadRequest.ActivationCode == dialogField.value())
                        {
      
                            switchValue = 1;
                            
                        }
                        switch (switchValue)
                        {
                            case 1:
                                journalTable = InventJournalTable::find(journalNum);
                                inventJournalCheckPost = InventJournalCheckPost::newJournalCheckPost(JournalCheckpostType::Post,journalTable);
                                inventJournalCheckPost.run();
                                break;
    
                            default:
    
                                break;
                        }                
                                
                    }
    
                  
                }
               
    
            }
            
    
            next postJournal(_journalTransList);
        }
    
     
    }
     
     
     
     
     
     
     
     
     
     
     
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 228,493 Most Valuable Professional on at
    How to Extend InventJournalCheckPost class
    I think you should extend checkJournal() method of the right descendant of JournalCheckPost class.
  • Faqruddin Profile Picture
    Faqruddin 1,867 on at
    How to Extend InventJournalCheckPost class
    Hello Bharani,
     
    There is no run() exists in the InventJournalCheckPost class. Please you can simulate any scenario and let us know how can we achieve this.
     
    Thanks.
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,572 Moderator on at
    How to Extend InventJournalCheckPost class
    Then in that case you can check the method where some validation code is present in the same.class. Like let's say some standard validation like validate(), checkjournal() method. These may or may be available in that class but similar code can be present. If you were not able to see any validation related then simply write the custom validation in run method.
  • Faqruddin Profile Picture
    Faqruddin 1,867 on at
    How to Extend InventJournalCheckPost class
    Hi,
     
    I have Custom field RequstID in InventJournalTable. If this field exists with the value than I need to allow user to post Transfer Journal else I need to stop it. But I'm not sure how can I wrap it with newPostJournal().
     
    Thanks
     
     
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 290,524 Super User 2024 Season 2 on at
    How to Extend InventJournalCheckPost class
    Hi Faqruddin,
     
    Please tell us from a functional point of view what you want to achieve.
  • Martin Dráb Profile Picture
    Martin Dráb 228,493 Most Valuable Professional on at
    How to Extend InventJournalCheckPost class
    You already know how to create an extension of newPostJournal(), but it seems that you have some problem with it that you forgot to mention.
     
    I also doubt it's the right place for you logic, but I can't really comment on it unless you describe your business requirements.

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

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

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,524 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,493 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans