How can I find the last tag in the AX2009?

I would like to insert all the shortcuts from the label ModuleId into the AX2009 table.

I have this job that does almost everything I need. But I have to enter max Id (toLabel = 1000):

static void OcShowAllLabel(Args _args) { xInfo xinfo; LanguageId currentLanguageId; LabelModuleId labelModuleId = 'OCM'; // hier evt eine Eingabe durch Benutzer zur Auswahl LabelIdNum frLabel; LabelIdNum toLabel = 1000; LabelId labelId; OcShowAllLabels_RS tab; Label blub = new Label(); str label; ; xInfo = new xInfo(); currentLanguageId = xInfo.language(); delete_from tab where tab.LanguageId == currentLanguageId && tab.LabelModuleId == labelModuleId; for (frLabel = 1; frLabel <= toLabel; frLabel++) { labelId = strfmt('@%1%2', labelModuleId, frLabel); label = SysLabel::labelId2String(labelId, currentLanguageId); if (labelId != label) { tab.initValue(); tab.LabelId = labelId; tab.Label = label; tab.LanguageId = currentLanguageId; tab.LabelModuleId = labelModuleId; tab.insert(); } } Info('done'); } 
+4
source share
3 answers

If this is a one-time job, you can just stop AOS and open the tag file in notepad. This is in your folder named axXXXen-us.ald, where XXX is the name of your tag file, and en-us is your language.

Take a look at the \ Tutorial_ThreadWork \ doTheWork classes to see where they use while (sLabel) instead of the for loop, as you have.

 container doTheWork(Thread t,LabelType searchFor) { container retVal; SysLabel sysLabel = new SysLabel(LanguageTable::defaultLanguage()); str slabel; ; slabel = sysLabel.searchFirst(searchFor); while (slabel) { retVal += sLabel; slabel = sysLabel.searchNext(); } return retVal; } 

Since the tag file is a text file, it makes sense that you cannot just select the latter, but you need to iterate over the file. However, AX caches tags, but I don’t think you can easily access the shortcut cache as far as I know.

Finally, I hope you do not try this, but do not try to just read the text file with the inscription, because AX sometimes has tags that it did not blush into this file from the cache. I think Label :: Flush (...) will clear them, but I'm not sure.

+1
source

Here is another option, I suppose. You can insert a label to get the following label number and then delete it immediately:

 static void Job32(Args _args) { SysLabel sysLabel = new SysLabel(LanguageTable::defaultLanguage()); SysLabelEdit sysLabelEdit = new SysLabeLEdit(); LabelId labelid; ; labelId = syslabel.insert('alextest', '', 'OCM'); info(strfmt("%1", labelId)); sysLabelEdit.labelDelete(labelId, false); } 

It seems to be consuming a number from a number sequence. You can simply execute Label :: Flush (...) and then check the text file with code. Take a look at Classes \ SysLabel * to see how the system works with tags. It doesn’t look very simple by any means.

+1
source

Here is another option that might work for you. This will also reveal missing shortcuts. Change "en-us" to your language. I guess this is a dirty alternative. Perhaps you need to add something to say "if we find 5 tags in a line where they look like" @OCM ".

 for (i=1; i<999; i++) { labelId = strfmt("@%1%2", 'OCM', i); s = SysLabel::labelId2String(labelId, 'en-us'); if (s like '@OCM*') { info (strfmt("%1: Last is %2", i, s)); break; } info(strfmt("%1: %2", i, s)); } 
+1
source

Source: https://habr.com/ru/post/1392973/


All Articles