Options

How to make a default key in a report?

pdjpdj Member Posts: 643
I have a simple report where I would suggest the user to use a certain key, a default key. (not the primary key)
But it should be possible for the user to pick any key he/she wishes. (including the primary key)

If I set a key in DataItemTableView it can't be changed by the user.
If I don't set a key in DataItemTableView I can't select a different default key. (Tried both OnInitReport and OnOpenRequestForm)

I can only see two solutions, which both are quite bad:

1) Execute the report from a codeunit. (Un-tested, but I think it will work)
2) Create a lookup (either a static dropdown or dynamic to the new Key table) and use the selected key in OnPreDataitem.

What am I missing?
Regards
Peter

Comments

  • Options
    David_SingletonDavid_Singleton Member Posts: 5,479
    This has annoyed me for as long as I have been using Navision. It would be nice if you could set a default and then let the user select a different key. There are a number of solutions to this, and all involve code.

    If you need to offer only a few keys (say the report is based on Item ledger entry table, and the first element of the key MUST be Item No. then you can just create a drill down on the options tab to determine which key to use.

    If the user will never select the primary key (say where primary key is Entry No), then you can add code to check the current key and if it is entry no, then you know the user did not select a key, so you can then set the default key.

    But you need to know more about the actual customer request before you can determine which is the best option.

    In most cases, I let the user select the key, and just train them properly. I am always in favor or raining over coding.
    David Singleton
  • Options
    pdjpdj Member Posts: 643
    The user already had two keys selectable in the requestform as you describe in your first solution. I was just surprised that I couldn't see a simple solution to make all keys selectable while keeping a default key. I actually started making a solution using the Key table, but it shows field names and not field captions. Then I would have had to make a solution with KeyRef and FieldRef instead. And that was "slightly" overkill for the change request...

    I simply ended up solving it by simply adding the third key they requested in the existing dropdown field. The new key they wished to use was the primary key, so I couldn't use your other suggestion.

    But thanks a lot for your reply - I feared I was the only one unable to see the simple solution :?
    Regards
    Peter
Sign In or Register to comment.