Hi there, we got an requirement to develop an lookup field for MainAccount form. As per the requirement, we need to add an condition and if that condition doesn't satisfies, i need to throw error message and clear the text in the field. I can able to throw error message and prevent saving it but cant able to clear record entered (after manually clearing record also still throwing error message). I had added coc for validatewrite() in my datasource table and trying to add condition from there. Please have a look at my table extension class code and suggest me accordingly.
It's very strange that your condition isn't related to the selected record at all - I think you forgot a 'where' condition in the query.
Clearing LocalLedgerAccount doesn't make any difference for the condition, because it doesn't use this field.
Hi Martin, if I add any condition to that join that the error condition is not triggering . I had type field in both MainAccount table and CNLLUXView (our customized view). The lookup field needs to validate the condition that MainAccount.Type == CNLLUXLocalAccountMapping.Type.
And the lookup field is in MainAccountLegalEntity Table thats where am trying to add validateWrite() for our condition
Please suggest accordingly.
I'm still not convinced that your select statement is correct. What is the point of checking data unrelated to what you're saving? Why don't you specify which MainAccount you want to check and you leave to the database server? You'll effectively get data for the first main account in the database, regardless of what main account you're actually saving.
It looks utterly wrong to me.
You can write the code in validateField but as Martin said the code is wrong.
As I understand it, You want select a localAcount. Then You want to check if the type of this account exists in the custom Type table.
In this case, you need to find the mainAccount with the localAcount you selected and join check the custom table with exists join.
If mainAccount.RecId is empty, you can throw an error in checkFailed in validateField
Since I do not know the relations between the tables, I cannot write in more detail, but the current query always gives the same result. It's no different than typing true or false instead of typing the query.
select firstOnly RecId from mainAccount where mainAccount.MainAccountId == this.LocalLedgerAccount exists join cnlLuxView where cnlLuxView.Type == mainAccount.Type; if(!mainAccount.RecId) { }
Maybe something like this
That helped alot. Thanks for the useful information.
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.
We are honored to recognize Mansi Soni as our August 2025 Community…
A new season of Super Users has arrived, and we are so grateful for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.