Labels

Showing posts with label Tips. Show all posts
Showing posts with label Tips. Show all posts

Friday, September 28, 2012

Simple notification service

In Microsoft Dynamics NAV 2009 platform new triggers OnDatabaseInsert, OnDatabaseModify, OnDatabaseDelete, OnDatabaseRename were added. They are fired even in code you don't call triggers  INSERT, MODIFY, DELETE with TRUE arguement. In standard functionality these triggers are used for integration with Microsoft Dynamics CRM product.
The Business Notification Server functionality is too complex and requires some additional granules, that costs some money. So, I 've created the alternative lightweight universal solution for notification. IT manager has the possibility to subscribe user for special events on any table. And user will get notification in his mailbox.

Friday, November 11, 2011

How to decide certain value satisfy filter conditions or not?

Imagine, you have the special field in setup table for defining filter conditions. It could contain a range of items or customers and looks like "C1000..C2000|C2500".
Now, when you proceeding certain record you would like to know, does the "No." of your record satisfies filter conditions or not. I think better way for this is to use filters:
   CustomersL.SETFILTER( "No.", '(%1)&%2', SetupL."Filter Conditions", ProceedingNo);
   IF CustomersL.FINDFIRST THEN MESSAGE('Record satisfies filter');
I hope this little tip would be useful.

Wednesday, October 12, 2011

Convenient way to add new records by copying its parameters from template

I think it would be very convenient if we could use Data Templates when creating new record.
This way users shouldn't do fool mistakes on filling some mandatory fields like posting groups, location codes etc.

Let's take for example Item table.

There are several issues why we can't use Form - OnNewRecord and Form - OnInsertRecord triggers. In the first case we can't insert new record, because the transaction could not be started there. In the second case 2 records would be created, 1st record is copied from template and 2nd is inserted with empty fields in a standard way.

That's why I've created new menubutton with F3 shortcut on Customer Card. This button should intercept event of creating item (pressing F3 key). The code of trigger is below:

Tuesday, July 12, 2011

Item lookup with built-in search

Let's take a look at the operations, that manager executes every time he adds new item to an order:
1. Pushes lookup in the No. field
2. Goes to a Description field and starts to write an item name.
3. Chooses a necessary item.
If a user knows an Item name, then he can write it directly in No. field. NAV will search for an Item, that begins with an entered phrase and insert it's code to a No. field. It is because of AltSearchField property, setted for the Item table.
But what if several items, which Description field contains entered phrase exists? NAV will find only first of them... It's not convinient and that's why users prefer searching items in the item list, spending more time for every line.

My suggestion is to let the user choose an item from a list, if there are several items, that complies his request. It's a kind like incadea does...

Subform detail or summary view

Often there is so many fields on a subform, that user become confused. It's a standard Navision way, that user can customize those fields, that he wants to view on the subform. But, I think, more user-friendly is to have a button, that switches from summary view to details if user wants to enter extra-data.
Lets take for example Sales Order. I've created 2 buttons, place them on each other below the subform: bSum & bDetails.
bSum is not Visible by default (property Visible = No), it means the Summary view will be shown by default and user can switch to Details.

Friday, June 24, 2011

Simple way to store password in database

Imagine, you want to store user password to access external NAV portal, and no one must see it.
You can, of course, set the property to PasswordText  = Yes on the form. But, what if the user press Ctrl + F8 to view fields inside the table? ...
So, let's write a little function to store protected password text.

Password - OnValidate()
Password := EncodeDecode(Password);



EncodeDecode(String : Text[30]) : Text[30]
FOR i := 1 TO STRLEN(String) DO
BEGIN
  Ch := String[i];
  Pass[i] := 255-Ch;
END;
EXIT(Pass);

So, you can use this function not only for encoding text, but also for decoding.

Tuesday, June 21, 2011

Parameter Setup

Usually I face a problem, that some constants should be stored in database. For example, complex report should be run and a hundreds of filters should be setted up. When running report user should have friendly interface with the number of parameters, that he can change (for example, date range), other filters should be not visible for him, but available for support. That's why I've created special table with simple structure:
1 Object Type      Option
2 Object           Integer
3 Parameter ID     Code[30]
4 Value            Text [250]  

Object ID field is related to Object table.
This flexible table allows not only setup parameters for reports, but for dataports and forms, too.

Also, the benefit is that it is not neccessary to add fields in standard Setup tables - less standard database modification.

In the conclusion let me bring a code for reading the parameter from this table, it is very simple:
ReportParameterSetup.GET(ReportParameterSetup."Object Type"::Report, 50163, 'CurrencyGUID');
CurrencyGUID := ReportParameterSetup.Value;