Choose Template Journal automatically


I got some problem that i need help with.

Our company, in Gen.Journal Template using two journal template with one source code.

The Source Code is CASHRECJNL

And we create one template name that use different form

CASHREC_1 use form 255 for user A <= this one is Native

CASHREC_2 use form 50120 for user B <= this one created by me

We choose to do this because we want user B only able accessing CASHREC_2.

In native NAV4 database there is Cash Receipt Journal in Sales & Receivable Menu.

When i click it, We will have to choose one of journal above.

Is there any way to code this so when i click Cash Receipt Journal, it enters CASHREC_2 without choosing which template i want to use?

For a single user or many users you want this functionality ?

Basically i just need help to skip template choosing.

I can limit which user to access by using role & permission to limit those form.

We did this change on the user setup, added a few extra fields and made a lookup against that to say use this journal only.

Add one field in Journal Template and write a code on OnOpenform trigger for filtering the record based on user. This will help you to resolve your problem.

So it looks like you have two questions? The first is on how to bypass the Journal Template selection list and go straight into the Cash Receipts Journal form. The second (inferred) question, if you haven’t already solved that, is on how to use user-based settings to determine which form object to open (255 or 50120).

If you have populated the Form ID field in your CASHREC_2 template to indicate form 50120, then you’ve already done the heavy lifting for launching different Cash Receipts Journal forms based on user settings.

To know which of the two Journal Templates any specific user should run, you’ll probably want to create new fields in User Setup - something like Def. Cash Rcpt. Jnl. Template and Def. Cash Rcpt. Jnl. Batch. Then you can use these setup fields to assign users to one of the Template/Batch combinations. The Template field you’ll definitely need. The Batch field is optional.

To bypass the Journal Template selection process when opening the Journal form, you’re basically going to write a function that will spoof the system into thinking that you’re trying to open the Journal and Batch from the General Journal Batches list page.

First, take a look at the code in the OnPush trigger of the Edit Journal command button control on the f_251 General Journal Batches. You’ll see that it’s making a call to c_230 GenJnlManagement, function TemplateSelectionFromBatch. You’ll want to write a function that filters the t_232 Gen. Journal Batch record based on the settings you’ll be adding to the User Setup table, and then passes it to the TemplateSelectionFromBatch function. To make it as versatile as possible, you might consider creating a codeunit that’s dedicated to this feature and that includes your new function. That way, if you are using RTC, you can create a menu item that runs the codeunit.

Once you’ve created this function, then you’ll add a menu item that calls it. This menu item will replace the current menu item that opens the Cash Receipt Journal.

This is just one of many possible functional options.