Select a record from a table when you only have the tableId
Tue Jan 23 2024 08:51:31 GMT+0000 (Coordinated Universal Time)
Saved by
@MinaTimo
// The following code can provide you a generic way to update a table when you only have the tableId.
public Common findRecord(TableId _tableId, RecId _recId, Boolean _forUpdate = false)
{
Common common;
DictTable dictTable;
;
dictTable = new DictTable(_tableId);
common = dictTable.makeRecord();
common.selectForUpdate(_forUpdate);
select common
where common.RecId == _recId;
return common;
}
// If you want, you can even update fields in this common record. You can Access/edit these fields by using their Name or FieldNum. The method below will update a specific field in a table.
public void updateValue(TableId _tableId, RecId _recId, str _field, AnyType _value)
{
Common common;
Int fieldId;
;
ttsbegin;
common = findRecord(_tableId, _recId, true);
fieldId = fieldname2id(_tableId,_field);
if (fieldId && _value)
{
common.(fieldId) = _value;
common.update();
}
ttscommit;
}
content_copyCOPY
Comments