dynamically validate dropdown based on another field value or null in idempiere

564 views
Skip to first unread message

Mousumi Bhowmick

unread,
Aug 20, 2018, 6:47:47 AM8/20/18
to iDempiere
I want to populate account based on account type using dynamic validation. Its working. But I also want if account type is not selected then, populate account dropdown with all values for all account types.

Dynamic Validation for account is:

CASE WHEN '@AccountType@' = 'A' THEN C_ElementValue.AccountType = 'A' WHEN '@AccountType@' = 'E' THEN C_ElementValue.AccountType = 'E' WHEN '@AccountType@' = 'L' THEN C_ElementValue.AccountType = 'L' WHEN '@AccountType@' = 'R' THEN C_ElementValue.AccountType = 'R'  ELSE C_ElementValue.AccountType in ( 'A' ,'E', 'R', 'L' ) END.

ELSE part is not working.  could anybody help me to identify what is missing here or there is any gap in understanding.

Carlos Antonio Ruiz Gomez

unread,
Aug 20, 2018, 10:53:00 AM8/20/18
to idem...@googlegroups.com
Hi Mousumi,

I think you can rewrite that to something easier like this:

(C_ElementValue.AccountType = '@AccountType@' OR '@AccountType@'='')

Regards,

Carlos Ruiz

Mousumi Bhowmick

unread,
Aug 20, 2018, 11:50:18 PM8/20/18
to iDempiere
Thanks Carlos, but its not working. I think this dynamic validation is not executed until I select account type. Without selecting account type how to get all account value?

Chuck Boecking

unread,
Aug 21, 2018, 2:10:35 PM8/21/18
to iDempiere
Hi Mousumi,

You can default the value in case the AccountType is null. Here is an excerpt from the ERP Academy:

@IsSOTrx:Y@=Y = shows how to default the value. This is demonstrated in System Admin role => Info Window => Business Partner => isCustomer field. 

Once you get past the context lookup throwing the error, you can write SQL to allow for all results unless an Account Type is specified.

I hope this helps!

Regards,

Chuck Boecking
512.850.6068 (office and cell)

I hope this helps

Mousumi Bhowmick

unread,
Aug 23, 2018, 12:08:12 AM8/23/18
to iDempiere
Hi Chuck,

Thanks for your suggestion. Account Type and Account is report params. How to add default value set in case of report params? My requirement is when I select account type then accordingly value will be filtered , otherwise for all account type , account list will be populated.


Regards,
Mousumi

Chuck Boecking

unread,
Aug 23, 2018, 9:16:00 AM8/23/18
to idem...@googlegroups.com
There is an applicable example of the SQL / Dynamic Validation in invoice (Vendor) window => Line subtab => Charge field. The Charge options are conditionally limited by Charge Type. The parameters behave the same way. Please confirm you achieved success.


Regards,


Chuck Boecking
512.850.6068 (office and cell)
ch...@chuboe.com
ChuckBoecking.com
chuck.boecking (skype)

**************************************************************************************************

PLEASE READ: The information contained in this e-mail is confidential  and intended 
for the named  recipient(s)  only. If  you are not  an intended recipient of this  e-mail 
please  notify the sender immediately and delete your copy  from your  system. Our 
company accepts no liability for any damage sustained as a result of viruses in this 
e-mail or any attachment(s) to it.

**************************************************************************************************

--
You received this message because you are subscribed to a topic in the Google Groups "iDempiere" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/idempiere/Ruqv2LugHrw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to idempiere+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/a01f344c-4f9a-46f5-a4be-2a9f5b7ef19c%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Mousumi Bhowmick

unread,
Aug 24, 2018, 2:35:20 AM8/24/18
to iDempiere
No, it does not help. According to dependency its working but loading all data considering all the account type is not working. What I think dynamic validation is not executed if account type is not selected.
To unsubscribe from this group and all its topics, send an email to idempiere+...@googlegroups.com.

Syed

unread,
Aug 24, 2018, 2:50:03 AM8/24/18
to iDempiere

Hi Mousumi,
I am sure that you can achieve your scenario using dynamic validation..

You may try this:
(C_ElementValue.AccountType = '@AccountType@' OR COALESCE('@AccountType@','')='')

If the above expression is still not working then you need to write dynamic validation based on what values are substituting in the dynamic validation expression when the accounttype is blank.
Just debug the code to write the right dynamic validation to meet your scenario.

Regards,
Syed.

Mousumi Bhowmick

unread,
Aug 24, 2018, 3:57:36 AM8/24/18
to iDempiere
Hi Syed,

could you please let me know the file name for report and process menu so that I can debug? Before submitting the report in report params this dynamic validation is added.

Regards,
Mousumi

Syed

unread,
Aug 24, 2018, 6:20:17 AM8/24/18
to iDempiere

I tested your scenario.. you are correct when AccountType is blank, there is no execution of dynamic validation. It just simply shows empty list.
To overcome this issue, you should clone AccountType reference list and add one more item "All" along with standard account types. Use this newly created reference list in your parameter configuration then you can easily write dynamic validation to list the account elements if "All" is selected.

To debug
MLookup.java
Line : 833

Chuck Boecking

unread,
Aug 24, 2018, 4:59:08 PM8/24/18
to idem...@googlegroups.com
Here is a quick example to allow field b to be updated based on a null value in field a. Notice that I updated https://test.idempiere.org/webui/ => Trial Balance report to make the Account drop down dependent upon Accounting Schema as a silly example. If you leave Accounting Schema blank, you only get only revenue accounts, otherwise, when you choose a schema you get all accounts. You just need to get creative with the SQL once you get past context throwing an error for a null value.






Regards,


Chuck Boecking
512.850.6068 (office and cell)
ch...@chuboe.com
ChuckBoecking.com
chuck.boecking (skype)

To unsubscribe from this group and all its topics, send an email to idempiere+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/47cdd0b7-df07-4a22-8eb6-48db51179ca5%40googlegroups.com.

Mousumi Bhowmick

unread,
Aug 28, 2018, 1:23:11 AM8/28/18
to iDempiere
Hi Chuck,

I am using 2.1.0.qualifier version, probably in this old version it is not working.

Regards,
Mousumi Bhowmick
Reply all
Reply to author
Forward
0 new messages