X++ Labels and TFS

It always happens at the most unfortunate moments that AX labels go crazy: You see a temporary label ID like $@AB1, or, even worse, labels are lost or overwritten. There never seems to be a good reason for this – this impression is partly due to the fact that one usually doesn’t realize the mess until some time after it was caused and then doesn’t see any relation to one’s actions.

Seeing that labels are not really interesting for a developer (I have to include myself here), it’s a shame that they can cause so much additional pain. So, I thought I’d share what process I always follow … without running into these issues. It may seem like some extra work, some extra steps, but once you had to „unmess“ some labels, you’ll understand why I don’t mind following my few simple rules:

  1. Add everything (to be exact: all elements using the new, temporary labels) to version control BEFORE checking in the label file.
  2. CHECK IN the label file FIRST, before checking in the artifacts using them.
  3. Make sure that the entire team uses the SAME language to CREATE NEW labels. This means:
    • When creating a new label, check out the label file of the common main language.
    • Create the new temporary labels you want to create.
    • Check in the label file.
    • Check out the label files of all the other languages and add the translations to the now final Label IDs.
  4. After checking in a label file, make sure that any CONFLICT RESOLUTION was done correctly, if not take immediate action.

Background information regarding these rules:

Re Rule 1
Temporary labels are only replaced with final labels for elements that are under version control.
Re Rule 2
This is easy: If the artifact is checked in before the final label IDs were generated, it’s read-only and cannot be modified to use the new label IDs.
Re Rule 3
Say that for some reason, the label files in different languages are out of sync:

  • In en-us the most recent label is XXX20, in de, it’s XXX15.
  • If you now check out both label files, but on check-in, AX decides to resolve the temporary labels starting with de, then your new label will get the ID XXX16. But, this ID is already used in en-us. There you are: Trouble!
  • Note that it might all work out ok if you always are sure that the IDs are in sync between all languages (you use). But, since the check-in doesn’t always allow for checking in all label files at once, you will run into problems sooner or later.
Re Rule 4
This always makes sense, not only for labels.