X++ “Cross reference” for extended data types

I wrote a job to check which fields uses a specific enum. This week I needed something similar for an extended data type and I modified it to work with EDTs instead.

The cross reference on the environment I am currently working on is not up to date. I used this job to find all the table fields that use this extended data type, similar to what the standard cross reference function does.

Simply change the extended data type in line 5 to the EDT you want to investigate, and the job makes a list of table fields that uses the EDT. You can also change the layer depending on what you are looking for.

For example, for InterCompanyCompanyId, searching through all the fields in the SYS layer:

  1. //Tina van der Vyver
  2. //makecreatereiterate.com
  3. static void edtCrossReference(Args _args)
  4. {
  5.     str                 edtName = extendedTypeStr(InterCompanyCompanyId);
  6.     ExtendedTypeId      edtId = extendedTypeName2Id(edtName);
  7.     UtilIdElements      utilfield;     
  8.     DictField           dictField;       
  9.  
  10.     setPrefix(strFmt("EDT: %1", edtName));
  11.  
  12.     while select parentId, utilLevel, Name, id from utilfield
  13.         where utilfield.recordType == UtilElementType::TableField        
  14.         && utilfield.utilLevel  == UtilEntryLevel::sys
  15.     {
  16.         dictField = new DictField(utilfield.parentId, utilfield.Id);
  17.  
  18.         if (dictField.typeId() == edtId)
  19.         {      
  20.             info(strFmt("%1: %2 - %3", utilfield.utilLevel, tableId2name(utilfield.parentId), dictField.name()));
  21.         }
  22.     }
  23. }

IntercompanyCompanyId crossreferance

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">