selectForUpdate with fieldId in D365Fo using x++ . Just check below method.
static void update(Args _args) { CustTable custTable; TestCustomer testCustomer; void updateByField(FieldId _testCustomerFieldId, FieldId _custTableFieldId) { if (custTable.(_custTableFieldId)) { testCustomer.(_testCustomerFieldId) = custTable.(_custTableFieldId); } } void updateTable(Common _tableBuffer) { if (_tableBuffer.validateWrite()) { _tableBuffer.update(); } } while select testCustomer { custTable = CustTable::find(testCustomer.CustAccount); if (custTable) { ttsBegin; testCustomer.selectForUpdate(true); updateByField(fieldNum(testCustomer, CustGroupId), fieldNum(custTable, CustGroup)); updateByField(fieldNum(testCustomer, Currency), fieldNum(custTable, Currency)); updateByField(fieldNum(testCustomer, Name), fieldNum(custTable, InventSiteId)); updateByField(fieldNum(testCustomer, NoYesId), fieldNum(custTable, InterCompanyDirectDelivery));
updateTable(testCustomer); ttsCommit; } } }
Before:
After run the method:
Output
No comments:
Post a Comment