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
0
Comments
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.
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 :?
Peter