with tableId and fieldname get to the field value on a Common table records

Sometimes, the developer needs of a given table based on records and the table field names, get to the field values. In fact,It's very simple, just on the common data record can be directly referenced in parentheses.

Please refer to the following code:

 

static void Jimmy_TableIdFieldNameGetValues(Args _args)
{
    CustTable   custTable;

    anytype GetFieldValue (Common _common, str _fieldName)
    {
        FieldId fieldId = fieldName2Id(_common.TableId, _fieldName);
        if (fieldId != nullValue(fieldId))
        {
            return _common.(fieldId);
        }
        throw error(strfmt('Table %1 does not contain Field %2.', 
            tableId2Name(_common.TableId),
            _fieldName));
    }
;
    select firstonly custTable;//the record
    
    info(any2str(GetFieldValue(custTable, 'Name')));
}

posted @ 2010-11-28 21:10  Fandy Xie  Views(253)  Comments(0Edit  收藏  举报