Search This Blog

Tuesday, September 6, 2011

Search Fields list based on EDT

The following code used to get the list of fields used EDT.
when you run this code you will prompt dialog with text box to enter the EDT Name. Provide EDT Name in the Text box and click on ok.Then you will get the info box with all the list of fields used in different tables.

static void krishh_FindFieldsByEDT(Args _args)
{
    Dictionary dictionary = new Dictionary();
    DictTable dictTable;
    DictField dictField;
    DictType dictType;
    Dialog                  dialog              = new Dialog('Search Fields based on EDT');
    DialogField             dialogEDTName     = dialog.addField(typeid(Name),'EDT Name');
    Int cntDict;
    Int cntFlds;
    Str EDTName;
    ;
    if (dialog.run())
    {
        EDTName = dialogEDTName.value();
    }
    dialog.close();
    if(EDTName=="")
     return;
    /* looping through tables */
    for (cntDict=1; cntDict<=dictionary.tableCnt();cntDict++)
    {
        dictTable = new DictTable(dictionary.tableCnt2Id(cntDict));
       /* looping through fields */
        for (cntFlds=1; cntFlds<=dictTable.fieldCnt();cntFlds++)
        {
            dictField = new DictField(dictTable.id(),dictTable.fieldCnt2Id(cntFlds));
            dictType = new DictType(dictField.typeId());
            if (dictField.type()==Types::UserType && dictType.name()like EDTName)
            {
                info('================================');
                info('Table Name:      ' + dictTable.name  ());
                info('Field Name:  ' + dictField.name());
                info('Base Type:   ' + Enum2Str(dictField.baseType()));
                info('EDT Type Name: ' + dictType.name());
            }
        }
    }
}

No comments:

Post a Comment

Thanks for visiting my blog,
I will reply for your comment within 48 hours.

Thanks,
krishna.