To Get all Labels in Dynamics Ax

Description:-
In this article we will get all labels through X++ in ax 2012. here is the example to get all labels file in Dynamics ax.

Code:-
static void FindUnUsedLabels()
{
  str 50 labelId;
  str labelString;
  int i;
  //set max label to the highest number of labelId in your application
  int maxLabel = 5000;
  xRefNames       names;
  XRefReferences  ref;
  ;
  while (i<= maxLabel)
  {
    //Sequential generation
    labelId = "@ANI" + int2str(i);
    //Find if the label id has an cross reference
    //record
    select recid from names where names.Name == labelid 
       exists join ref where names.RecId == ref.xRefNameRecId;
    labelString = SysLabel::labelId2String(labelId);
    //If there is no record in cross reference then log it
    if (! names.RecId&&
    //avoid logging labels that are already deleted (This is because of sequential check like IFC1, IFC2, IFC3etc…)
    labelString != labelId)
    {
      info(strfmt("%1 – %2\n", labelId, SysLabel::labelId2String(labelId)));
    }
    i++;
  }
}

Related Posts

Previous
Next Post »

Thanks for comments.....