The following code can provide you a generic way to update a table when you only have the tableId.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| 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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| 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;
} |
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.