parm issue
-
- Experienced User
- Posts: 147
- Joined: Tue Jun 17, 2014 4:00 pm
- First Name: Patti
- Last Name: Bednarz
- Company Name: McGard
- State / Province: New York
- Country: United States
- Contact:
parm issue
I am loading the contents of a select box from a data-base driven selection with a select statement that accepts 4 parms. The statement works properly if I omit the last 2 parms (which are date fields). It does not work if I include them. I am enclosing the "on change" code and data-base driven selection code. Can you help me make the selection work with all 4 parms? Thank you, Patti
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: parm issue
The tricky thing about date fields in database-driven fields... the date must be in the format of YYYY-MM-DD (the *ISO format).
Since the code you're using to set the parameter values is JavaScript, the data will always be supplied as a character string. JavaScript does not have a "date type field" primitive like RPG does, so it'll always be a string. This is no problem, since SQL will automatically convert a string to a date if it's recognized in the date format.
I think our SQL-driven components always use the format YYYY-MM-DD. So if you can manipulate your date into that format, it should work.
Since the code you're using to set the parameter values is JavaScript, the data will always be supplied as a character string. JavaScript does not have a "date type field" primitive like RPG does, so it'll always be a string. This is no problem, since SQL will automatically convert a string to a date if it's recognized in the date format.
I think our SQL-driven components always use the format YYYY-MM-DD. So if you can manipulate your date into that format, it should work.
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: parm issue
For example, let's say you have a date field set up like this:
Since this date field is configured to be in MM/DD/YY format (because that's what the user finds the most friendly for this example) the get("INVDAT") call for this field would also return a string in MM/DD/YY format. To make it work with SQL, we'll need to flip it around. So in your onchange event for the date field, you'd put code like this:
Of course, your date field might be a different format, and I know it had a different field name, etc... so you'll need to adjust the code accordingly, but hopefully this gets you pointed in the right direction.
Since this date field is configured to be in MM/DD/YY format (because that's what the user finds the most friendly for this example) the get("INVDAT") call for this field would also return a string in MM/DD/YY format. To make it work with SQL, we'll need to flip it around. So in your onchange event for the date field, you'd put code like this:
Code: Select all
// Date in INVDAT field is in MM/DD/YY format
// but for the SQL we need YYYY-MM-DD format
// so rearrange it here:
var datemdy = get("INVDAT");
var dateiso = "20" + datemdy.substr(6,2)
+ "-" + datemdy.substr(0,2)
+ "-" + datemdy.substr(3,2);
// set the parameter value and re-load the drop-down
applyProperty("mySelect", "parameter value 3", dateiso);
applyProperty("mySelect", "field type", "select box");
-
- Experienced User
- Posts: 147
- Joined: Tue Jun 17, 2014 4:00 pm
- First Name: Patti
- Last Name: Bednarz
- Company Name: McGard
- State / Province: New York
- Country: United States
- Contact:
Who is online
Users browsing this forum: No registered users and 3 guests