1

I would like ask if it is possible to find the fieldId of a specific table through the labelId of the field.

Thanks in Advance

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
Nikos Kou
  • 175
  • 3
  • 17
  • Is this for getting a list of all fields (and tables) that references a particular label ID? – jp2g Apr 17 '18 at 07:08

2 Answers2

3

Use Cross Reference. Via interface:

  1. Tools \ Label \ Label Editor
  2. Enter LabelID in Find what field
  3. Click on Used by button
  4. Find Tables, Maps or Views in the list

You sould generate Cross reference before (Tools \ Cross reference \ Periodic \ Update)

Used by

mazzy
  • 1,025
  • 1
  • 13
  • 26
  • A good approach if the label is used on the table field directly (maybe that's exactly what @Nikos Kou needs), and not on an extended data type or an enum used by the table field. – 10p Apr 18 '18 at 08:55
  • See more crossrefs if a label used on the EDT, enum, report, form, confkey and other AOT objects. Use button `Add-ins \ Cross-reference \ Used by` to continue exploring deeper – mazzy Apr 19 '18 at 07:02
2

One of the possible solutions:

static void FindTableFieldsByLabel(Args _args)
{
    TableId         tableId     = tableNum(AccountingDistribution);
    str             findLabel   = literalStr('@SYS132687');
    SysDictTable    dictTable;
    SysDictField    dictField;
    FieldId         fieldId;

    dictTable   = new SysDictTable(tableId);
    fieldId     = dictTable.fieldNext(0);

    while (fieldId)
    {
        dictField = dictTable.fieldObject(fieldId);

        if (dictField.isSql() && !dictField.isSystem()
            && dictField.labelLabel() == findLabel)
        {
            info(strFmt('Field name: %1', dictField.name()));
        }

        fieldId = dictTable.fieldNext(fieldId);
    }

    info('Job completed');
}

You can also use dictField.labelDefined() if you want to ignore the labels set on extended data types and not on the table fields.

10p
  • 5,488
  • 22
  • 30