dinsdag 31 augustus 2010

Retrieve label of EDT

How to get the label of an EDT?

See \Classes\DialogField\init
setting the label:
o.label(dictType.label(f));
with the dictType being:
dictType = new DictType(xtype);
and xtype being:
xtype = type >> 16;


Why do we have to right shift 16?
see \Classes\SysDictField\new
there you find a left shift 16
and global::fieldExt2Id does:
return (fieldExtId & 0xffff);

Also see http://www.eggheadcafe.com/software/aspnet/29515376/addfield-parameters.aspx
exerpt:
typeid() function gives you the id of a type. For eg:
you can try the following code in a job:
static void job1()
{;
print typeid(custAccount);
pause;
}
This will print out 6488075. In the AOT if you check up the ID of CustAcount
it is 99. But the above number that get from typeid function is a
combination of the ID in the AOT and the flag indicating that it is a user
type. The upper 16 bits contain the ID from the AOT (99)and the lower 16
bits contain the flag that it is a user type (11)
6488705 == (99 << 16 | 11)


Example:
public boolean validate(Object calledFrom)
{
    boolean ret;
    ToDate todate;
    dictType dictTypeLocal;
    ;


    ret = super(calledFrom);


    if (!toDate)
    {
        dictTypeLocal = new dictType(typeId(todate) >> 16);
        ret = checkfailed (strfmt("@SYS110217", dictTypeLocal.label()));


    }
    return ret;
}


Example - short version:
static void Job8(Args _args)
{
;
info(new dictType(typeId(ToDate) >> 16).label());
}



In Global Class:
public static LabelString aduTypeLabel(extendedTypeId _typeId)

{
;
return new dictType(_typeId >> 16).label();
}


Also (this example is a static method on ConfigTable):
static FieldLabel aduLabel()

{
;
return new SysDictType(extendedtypenum(ConfigId)).label();
}

Geen opmerkingen:

Een reactie posten