setCurrentKey no longer crashes if missing

txerifftxeriff Member Posts: 401
edited 2021-11-18 in NAV Three Tier
Hi all,
I just want to confirm something.

I would say in old nav versions if they key didnt exist it simply used to fail. It seems like, now it searches for best ocurrence of index fields for the given setcurrentkey:

https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/record/record-setcurrentkey-method

Strange also, I tried random fields not included in any key and it always returns "true" for:
[Ok := ]  Record.SetCurrentKey(Field1: Any [, Field2: Any,...])

I even tried a calcsums and it worked.

Answers

  • bbrownbbrown Member Posts: 3,164
    Correct. You do not need to have a matching key. This has been for several versions
    There are no bugs - only undocumented features.
  • txerifftxeriff Member Posts: 401
    Yeah, thanks. later on I´ve found a document, seems like this started with NAV 2016. The risk here is you forget about creating the key, I would prefer it to fail or maybe an extra parameter true/false to "force" match they key.
Sign In or Register to comment.