How can I Open payment journal only for specific journal batch/user type

colingbradleycolingbradley Member Posts: 162
I have different user 'types'

New field in the Gen. Journal Batch table (232) "User Type"
User Setup new field "User Type".

When the user opens the Payment Journal, I can filter on the batch table if they look it up.

Problem:

If the last used batch was for BANK which is not within the filter, that batch opens up with whatever lines are in that journal.

I need to prevent the 'last used' and force a selection from the allowed list of batches.

I cannot find the insertion point for my filter code.

Any suggestions please.
Experience is what you get when you hoped to get money

Comments

  • loggerlogger Member Posts: 126
    Hi @colingbradley ,
    E.g. if you want to customize page 39, take a look at OnOpenPage trigger. You can see there GenJnlManagement.OpenJnl function which one is your key.
    Let's go!
  • colingbradleycolingbradley Member Posts: 162
    Still not able to control it. Tried the following to force it:

    CurrentJnlBatchName := 'LEGALTEAM';
    GenJnlManagement.OpenJnl(CurrentJnlBatchName,Rec);

    Did not work, just ignored that and opened up the GENERAL batch.
    Experience is what you get when you hoped to get money
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    It is a bit tricky as you must pass the the batch name both as a value and as a filter.

    Don't change the Page 39, try this instead:
    GenJnlLn.SETRANGE("Journal Template Name", 'GENERAL');
    GenJnlLn."Journal Batch Name" := 'LEGALTEAM';
    GenJnlLn.SETRANGE("Journal Batch Name", GenJnlLn."Journal Batch Name");
    PAGE.RUN(PAGE::"39", GenJnlLn);
    
    GenJnlLn."Journal Batch Name" := 'LEGALTEAM'; ... is needed in case your journal is empty - in such case SetupNewLine uses the value passed in the actual field to create new journal line

    GenJnlLn.SETRANGE("Journal Batch Name"... is needed for OpenJnl function called in OnOpenPage as it tries to get the requested batch name from the filter
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • loggerlogger Member Posts: 126
    @Slawek_Guzek , you are right in the case if @colingbradley calls page 39 not from main menu directly. But what if he does?
    Let's go!
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    If I need to open a Page from a menu which requires some prior data/filter manipulation I usually call the codeunit from the menu, and in that codeunit call the required page..

    It's just the way I prefer doing things. I prefer the model where the calling/parent object decides what called object is supposed to do/display. And I'm always trying to minimize the amount of code/changes on pages/reports.
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • colingbradleycolingbradley Member Posts: 162
    Thanks Slawek, there may be a problem with RTC re the icon when calling a Codeunit when the user is expecting a Page icon.
    However, I am able to add it to a new menu as stand alone and your concept works very well.
    Many thanks.
    Experience is what you get when you hoped to get money
  • colingbradleycolingbradley Member Posts: 162
    meant search bar image
    Experience is what you get when you hoped to get money
  • colingbradleycolingbradley Member Posts: 162
    NAV2017
    I am getting a different view of the Payment Journal when Run from the Codeunit.
    Some of the Actions do not appear but are all there if using the standard menu.
    Pity, otherwise it works really well.
    Experience is what you get when you hoped to get money
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    Payment Journal is different Page - 256. Could it be the reason?

    Journal specific pages are configured in Gen.Journal Template table. You may want to add something similar to your code to pick the right one:
    GenJournalTemplate.GET(YourTemplateCode);
    // previous code 
    PAGE.RUN(GenJournalTemplate."Page ID", ,GenJnlLn)
    
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • colingbradleycolingbradley Member Posts: 162
    Not that, just using the standard page.
    However, the boss now wants multiple list pages and not the direct open approach.
    So, the problem is not solved, just not in need of a solution.
    Will just have to pack that one away for some other time.
    Thanks so much for your responses.
    Experience is what you get when you hoped to get money
Sign In or Register to comment.