Tuesday, February 9, 2010

Find the length of an Extended Data Type in X++

Need to find the string length of a property in the AOT (e.g. AccountNum is a string size of 20). Below is some code that will do this for you. It will also allow you draw out some other properties of the EDT if you need to.

static void Job1(Args _args)
     str edtName = 'NAME_OF_EDT_OBJECT'
     Dictionary dictionary = new Dictionary();
     DictType dictType = dictionary.typeObject(dictionary.typeName2Id(edtName));

     info (strFmt('Size of %1: %2', edtName, dictType.stringLen()));