Page 1 of 1

Choice selection value with leading spaces

Posted: Wed Aug 08, 2018 4:25 pm
by ChristianB
Hello.

We have an issue with a select box that is loaded using a database driven selection.
We would like to restrict the list of items, using "choices selection criteria" and "choices selection value".
We set up those fields as follows :
choices selection criteria = ABMCU=?
choices selection value = ' R001'
The choice selection value has 8 leading spaces in our database field ABMCU.
This does not return any choice (the list is empty).

We tried also TRIM(ABMCU)=? together with 'R001' but it does not work.

Can you help us in fixing this problem ?

Thanks and regards.
Christian.

Re: Choice selection value with leading spaces

Posted: Wed Aug 08, 2018 4:54 pm
by Scott Klement
I tried this (I created a file with a field named ABMCU, gave it 8 leading blanks followed by R001) and it worked fine for me.

Two things that I noted:

1. You MUST do TRIM(ABMCU)=? in the selection criteria (but, you said you did that.)

2. You cannot include the quote marks. So the parameter value must be R001 and not 'R001' -- otherwise, it'll expect the data to also have quote marks in it.

Good luck

Re: Choice selection value with leading spaces

Posted: Thu Aug 09, 2018 4:19 am
by ChristianB
Hello.

I tried exactly TRIM(ABMCU)=? and choice parameters value : R001 (without quotes) : it does not work.
Surprisingly TRIM(ABMCU)='R001' without any choice parameters value is working fine.
I also tried to bind the value to a program field that contains ' R001' without success.
I made several tests (see the attached word document) and I now have the feeling that the problem is only related to ALPHA fields.
I also attached the AS400 table I am using for this test as a SAVF (I had to rename it with the .txt to be able to attach it to this ticket).

A quick fix could be to build the choice selection criteria dynamically and get rid of the choice parameter value. Is that possible ?

Thanks for your support.
Christian.

Re: Choice selection value with leading spaces

Posted: Thu Aug 09, 2018 4:07 pm
by Scott Klement
Hi Christian,

When I ran your example, I got an error. I don't know if you looked to see if you were getting any error messages? You didn't post it here.

an easy way to see an error is to set the ondbload event to code like this:

Code: Select all

if (!response.success) {
  pui.showLastError();
}
This tells Genie that when the SQL statement wasn't successful, it should show the error message on the screen.
More information about ondbload can be found here:
http://www.profoundlogic.com/docs/displ ... load+event

With that change, when I ran your example that used the parameter marker, I got this error:
cb_error.png
cb_error.png (5.11 KiB) Viewed 2499 times
Since you did not provide any error messages, I do not know if you received the same error? Please check and see if that is the case.

If you did get this error, you can fix it using the options shown here:
http://www.profoundlogic.com/docs/displ ... +as+EBCDIC

Once I enabled the "read db driven data as ebcdic" option from the preceding link, it worked properly for me.
cb_success.png
cb_success.png (5.8 KiB) Viewed 2499 times

Re: Choice selection value with leading spaces

Posted: Fri Aug 10, 2018 5:12 am
by ChristianB
Hi Klement,
Waouh !
It works perfectly after adding pui["read db driven data as ebcdic"] = true; into custom.js.
Thank you so much.
Christian.