Notifications
Announcements
No record found.
Hi,I want when we insert a new account bank account where the Remainder is ticked to true or if the amount >0 in Employee self service-- then update vendor bank account related to the account. The things is PayrollBankAccountDisbursement gets inserted after HcmWorkerBankAccount. So how i'm going to check the Remainder/amount values in PayrollBankAccountDisbursement [ExtensionOf(tableStr(HcmWorkerBankAccount))] final class HcmWorkerBankAccountTable_Extension { public void insert() { next insert(); if(this.check()) /// how to do the check heree?? as i don't have the remainder and amount values { this.createOrUpdateVendBank(); } } public void update() { next update(); if(this.check()) { this.createOrUpdateVendBank(); } } }
[ExtensionOf(tableStr(HcmWorkerBankAccount))] final class HcmWorkerBankAccountTable_Extension { public void insert() { next insert(); if(this.check()) /// how to do the check heree?? as i don't have the remainder and amount values { this.createOrUpdateVendBank(); } } public void update() { next update(); if(this.check()) { this.createOrUpdateVendBank(); } } }
So, you will be giving the bank account, amount and Remainder on the above form you have posted?
So that is the case you can write the logic in the "What is your bank account" form itself right?
You can utilize closeOk of the form to get the values- check the amount and remainder values >> Based on that update the account.
Thanks,
Girish S.
Hi Girish,
I updated the code above...
shouldn't the code be in the table i want to work like that also from table level
What is the use of the form you have posted above?
Can you elaborate more on this then we will decide where to write the code.
The self service should just be for the employee to amend their own details.
So do you think form is enough? not sure if there could be a case in the future.
Should it be on closeOk or Ok clicked method?
You need to write your logic in closeOk method. So, this method will be called after closing the form without any errors. This method is available at form level.
Would the whole process fail if the logic i will put in close ok fail? because it should
First you try to add the logic in closeOk and check whether it fulfill your requirement.
My logic worked, but if there are any errors with updating the vendor bank, then it will still create the bankAccount.
So I'm assuming i need to change the logic placeWould the OKButton be a good place? or can i do it on table level?
[ExtensionOf(formStr(ESSDirectDepositEntry))] final class ESSDirectDepositEntry_Extension { public void closeOk() { FormDataSource payrollBankAccountDisbursementDS = this.dataSource(formDataSourceStr(EssDirectDepositEntry, PayrollBankAccountDisbursement)); PayrollBankAccountDisbursement payrollBankAccountDisbursement = payrollBankAccountDisbursementDS.cursor(); if(payrollBankAccountDisbursement.IsRemainder == NoYes::Yes) { FormDataSource hcmWorkerBankAccounttDS = this.dataSource(formDataSourceStr(EssDirectDepositEntry, HcmWorkerBankAccount)); HcmWorkerBankAccount workerBankAccount = hcmWorkerBankAccounttDS.cursor(); ttsbegin; this.createOrUpdateVendBank(workerBankAccount); ttscommit; } next closeOk(); } private void createOrUpdateVendBank(HcmWorkerBankAccount _workerBankAccount) { HcmWorker worker = HcmWorker::find(_workerBankAccount.Worker); VendTable vendTable = VendTable::findByPartyRecId(worker.Person, true); VendBankAccount vendBank; if(vendTable) { select firstonly forupdate vendBank where vendBank.VendAccount == vendTable.AccountNum; PayrollBankAccountDisbursement payrollBankAccountDisbursement; select firstonly payrollBankAccountDisbursement where payrollBankAccountDisbursement.WorkerBankAccount == _workerBankAccount.RecId; if (vendBank.RecId == 0) { vendBank.initValue(); vendBank.AccountID = _workerBankAccount.AccountId; vendBank.VendAccount = vendTable.AccountNum; } vendBank.AccountID = _workerBankAccount.AccountId; vendBank.AccountNum = _workerBankAccount.AccountNum; vendBank.BankAccountType = _workerBankAccount.BankAccountType; vendBank.BankCodeType = _workerBankAccount.BankCodeType; vendBank.BankIBAN = _workerBankAccount.BankIBAN; vendBank.CellularPhone = _workerBankAccount.CellularPhone; vendBank.ContactPerson = _workerBankAccount.ContactPerson; vendBank.Email = _workerBankAccount.Email; vendBank.Location = _workerBankAccount.Location; vendBank.Location = _workerBankAccount.Location; vendBank.Name = _workerBankAccount.Name; vendBank.Phone = _workerBankAccount.Phone; vendBank.PhoneLocal = _workerBankAccount.PhoneLocal; vendBank.RegistrationNum = _workerBankAccount.RegistrationNum; vendBank.SWIFTNo = _workerBankAccount.SWIFTNo; vendBank.TeleFax = _workerBankAccount.TeleFax; vendBank.Telex = _workerBankAccount.Telex; vendBank.URL = _workerBankAccount.Url; vendBank.CurrencyCode = vendTable.Currency; if (vendBank.RecId == 0) { vendBank.insert(); } else { vendBank.update(); } if(vendTable.BankAccount != vendBank.AccountID) { vendTable.BankAccount = vendBank.AccountID; vendTable.Update(); } } else { throw error(strFmt('@XX:WorkerVendorBankAccountError', worker.name())); } } }
If you want to restrict the creation of bank account when vendor bank update failed - Then add your logic in the validateWrite method of form DataSource. Add the same logic inside the validateWrite method of worker bank account DataSource.
[ExtensionOf(formdatasourcestr(FormName, DataSourceName))] final class ClassName_Extension { public boolean validateWrite() { boolean ret; ret = next validateWrite(); if (ret) { if(vendTable) { //add your logic to update vend table } else { ret = checkfailed("Error message"); } } return ret; } }
so it's not doable on table level?
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 611 Most Valuable Professional
André Arnaud de Cal... 529 Super User 2025 Season 2
Sohaib Cheema 285 User Group Leader