Linked auto-complete fields
-
- Profound User
- Posts: 27
- Joined: Tue Feb 07, 2012 11:29 am
- First Name: john
- Last Name: holsombach
- Company Name: stoneriver, inc.
- Contact:
Linked auto-complete fields
I have a situation where i want to enable the auto-complete using database driven properties. The catch though is the results of some fields are going to be dependent on the choices selected in other boxes.
For instance, I have an agent entry setup that looks like this:
Agent # Producer Rate
XXXXX XXXXX XXX.XX
The agent # field will have auto-complete support based on the agent file.
The producer field will have auto-complete support based on the producer file, however the producers that should be displayed as choices are dependent on the agent selected.
The same with the rate field. Which rates are available is dependent on which producer is selected.
How can i change my selection criteria for the producer and rate boxes to update based on the selection entered in the agent and producer fields?
The idea is not to go back to the server since that would invoke some possible delays each time one of these fields is populated.
For instance, I have an agent entry setup that looks like this:
Agent # Producer Rate
XXXXX XXXXX XXX.XX
The agent # field will have auto-complete support based on the agent file.
The producer field will have auto-complete support based on the producer file, however the producers that should be displayed as choices are dependent on the agent selected.
The same with the rate field. Which rates are available is dependent on which producer is selected.
How can i change my selection criteria for the producer and rate boxes to update based on the selection entered in the agent and producer fields?
The idea is not to go back to the server since that would invoke some possible delays each time one of these fields is populated.
- Brian
- Profound Logic Staff Member
- Posts: 286
- Joined: Thu Apr 14, 2011 10:23 am
- First Name: Brian
- Last Name: May
- Company Name: Profound Logic Software
- Contact:
Re: Linked auto-complete fields
you could retrieve the value of the other field in your selection criteria.
your selection criteria would look something like this
js: "FieldName = '" + get("ID") + "'"
where ID is the ID of the previous element.
your selection criteria would look something like this
js: "FieldName = '" + get("ID") + "'"
where ID is the ID of the previous element.
-
- Profound User
- Posts: 27
- Joined: Tue Feb 07, 2012 11:29 am
- First Name: john
- Last Name: holsombach
- Company Name: stoneriver, inc.
- Contact:
Re: Linked auto-complete fields
I implemented the logic you listed, however it is not working.
I set up a text box on my screen which is a 9.0 numeric field with zero fill flagged and its initially set to a 0 value.
I have another text box, with database driven auto-complete set up. I have my selection criteria set to: js: "AAFND = " + get("TxbFein")
launching my program, i replace the 000000000 with a value of 999 and then using firefox debug, i found the following for my results:
query=0&AUTH=C88B11E72EDEF03D8C8727681B0021B9FDCF6792094F88BABAE35C0374E36A568CDA261D415B6DE9AD107B5F&context=rpgsp&task=autocomplete&sql=SELECT%20AAAGT%23%20%7C%7C%20'%20-%20'%20%20%7C%7C%20AANAME%2CAAAGT%23%20FROM%20WMAAP%20WHERE%20UPPER(AAAGT%23%20%7C%7C%20'%20-%20'%20%20%7C%7C%20AANAME)%20LIKE%20'%250%25'%20AND%20AAFND%20%3D%20000000000
So what it did was use 000000000 for my selection criteria, which is the old value of the 1st textbox (TxbFein).
Does the javascript only get run when the screen loads or should it run whenever i type a value to search in the box?
It appears that its not picking up the current value of my TxbFein box but the value the box had when the page loaded.
I set up a text box on my screen which is a 9.0 numeric field with zero fill flagged and its initially set to a 0 value.
I have another text box, with database driven auto-complete set up. I have my selection criteria set to: js: "AAFND = " + get("TxbFein")
launching my program, i replace the 000000000 with a value of 999 and then using firefox debug, i found the following for my results:
query=0&AUTH=C88B11E72EDEF03D8C8727681B0021B9FDCF6792094F88BABAE35C0374E36A568CDA261D415B6DE9AD107B5F&context=rpgsp&task=autocomplete&sql=SELECT%20AAAGT%23%20%7C%7C%20'%20-%20'%20%20%7C%7C%20AANAME%2CAAAGT%23%20FROM%20WMAAP%20WHERE%20UPPER(AAAGT%23%20%7C%7C%20'%20-%20'%20%20%7C%7C%20AANAME)%20LIKE%20'%250%25'%20AND%20AAFND%20%3D%20000000000
So what it did was use 000000000 for my selection criteria, which is the old value of the 1st textbox (TxbFein).
Does the javascript only get run when the screen loads or should it run whenever i type a value to search in the box?
It appears that its not picking up the current value of my TxbFein box but the value the box had when the page loaded.
- Brian
- Profound Logic Staff Member
- Posts: 286
- Joined: Thu Apr 14, 2011 10:23 am
- First Name: Brian
- Last Name: May
- Company Name: Profound Logic Software
- Contact:
Re: Linked auto-complete fields
So what you need to do is force the textbox to rerender when the other text box changes.
You can add the following to the onchange property of the first textbox to force textbox2 to rerender.
applyProperty("Textbox2", "field type", "textbox");
Textbox2 should be the ID of the textbox to reload. This assumes you are using textboxes. If you are using "combo box" or "select box" widgets, use the appropriate type on the last parameter.
You can add the following to the onchange property of the first textbox to force textbox2 to rerender.
applyProperty("Textbox2", "field type", "textbox");
Textbox2 should be the ID of the textbox to reload. This assumes you are using textboxes. If you are using "combo box" or "select box" widgets, use the appropriate type on the last parameter.
-
- Profound User
- Posts: 27
- Joined: Tue Feb 07, 2012 11:29 am
- First Name: john
- Last Name: holsombach
- Company Name: stoneriver, inc.
- Contact:
Re: Linked auto-complete fields
I'm getting the following for an error when my screen loads:
Expression 'applyProperty("TxbAgentNumber1", "field type", "textbox");' contains an error: a is null
Expression 'applyProperty("TxbAgentNumber1", "field type", "textbox");' contains an error: a is null
-
- Profound User
- Posts: 27
- Joined: Tue Feb 07, 2012 11:29 am
- First Name: john
- Last Name: holsombach
- Company Name: stoneriver, inc.
- Contact:
Re: Linked auto-complete fields
I'm not getting the error popup anymore however the javascript is not working either.
In my agent box, i have the selection criteria set to:
js: "AACO# = " + get("OutCo#") + " AND AAFND = " + get("DrpPopGroup")
In my dropdown list, i have the following for the onchange event property:
js: applyProperty("TxbAgentNumber1", "field type", "textbox");
Two things about this:
1) I'm never getting a value from my dropdown list box. the value parameter is set to a bound program field which i pre-populate with my default FND value.
2) When i change my selection in the dropdown list, i'm not seeing the new value in my agent box for my selection criteria.
I decided to try testing this with just a regular text box with a numeric value bound to it. The box is initially populated with a value of 000000000 (9.0 field with 0 fill).
I change the value of the field to 999 but my selection criteria continues to use the value of 000000000. The applyProperty function does not appear to be working.
In my agent box, i have the selection criteria set to:
js: "AACO# = " + get("OutCo#") + " AND AAFND = " + get("DrpPopGroup")
In my dropdown list, i have the following for the onchange event property:
js: applyProperty("TxbAgentNumber1", "field type", "textbox");
Two things about this:
1) I'm never getting a value from my dropdown list box. the value parameter is set to a bound program field which i pre-populate with my default FND value.
2) When i change my selection in the dropdown list, i'm not seeing the new value in my agent box for my selection criteria.
I decided to try testing this with just a regular text box with a numeric value bound to it. The box is initially populated with a value of 000000000 (9.0 field with 0 fill).
I change the value of the field to 999 but my selection criteria continues to use the value of 000000000. The applyProperty function does not appear to be working.
- David
- Profound Logic Staff Member
- Posts: 690
- Joined: Fri Jan 04, 2008 12:11 pm
- First Name: David
- Last Name: Russo
- Company Name: Profound Logic Software
- Contact:
Re: Linked auto-complete fields
It's hard to understand how the screen is to work without having a look at it. Can you attach a copy of the display file DDS? This will help us to understand better.
-
- Profound User
- Posts: 27
- Joined: Tue Feb 07, 2012 11:29 am
- First Name: john
- Last Name: holsombach
- Company Name: stoneriver, inc.
- Contact:
Re: Linked auto-complete fields
i've attached a text file of the screen.
To sum up
The agent # box's selection criteria is dependent on the company # output field and the fund dropdown box. The output field will not change so we only need to check the onchange event for the fund dropdown box.
The REFFLD settings can be replaced as follows:
A SCAGENT1 R H REFFLD(AHAGT# WMAHP) 5.0
A SCAGENT2 R H REFFLD(AHAGT# WMAHP) 5.0
A SCAGENT3 R H REFFLD(AHAGT# WMAHP) 5.0
A SCCO# R H REFFLD(EMCO# WMEMP) 3.0
A SCFEIN R H REFFLD(EMFEIN WMEMP) 9.0
A SCFND R H REFFLD(ELFND WDELP) 5.0
A SCPROD1 R H REFFLD(AHPROD WMAHP) 5.0
A SCPROD2 R H REFFLD(AHPROD WMAHP) 5.0
A SCPROD3 R H REFFLD(AHPROD WMAHP) 5.0
A SCRATE1 R H REFFLD(AHRT# WMAHP) 3.0
A SCRATE2 R H REFFLD(AHRT# WMAHP) 3.0
A SCRATE3 R H REFFLD(AHRT# WMAHP) 3.0
To sum up
The agent # box's selection criteria is dependent on the company # output field and the fund dropdown box. The output field will not change so we only need to check the onchange event for the fund dropdown box.
The REFFLD settings can be replaced as follows:
A SCAGENT1 R H REFFLD(AHAGT# WMAHP) 5.0
A SCAGENT2 R H REFFLD(AHAGT# WMAHP) 5.0
A SCAGENT3 R H REFFLD(AHAGT# WMAHP) 5.0
A SCCO# R H REFFLD(EMCO# WMEMP) 3.0
A SCFEIN R H REFFLD(EMFEIN WMEMP) 9.0
A SCFND R H REFFLD(ELFND WDELP) 5.0
A SCPROD1 R H REFFLD(AHPROD WMAHP) 5.0
A SCPROD2 R H REFFLD(AHPROD WMAHP) 5.0
A SCPROD3 R H REFFLD(AHPROD WMAHP) 5.0
A SCRATE1 R H REFFLD(AHRT# WMAHP) 3.0
A SCRATE2 R H REFFLD(AHRT# WMAHP) 3.0
A SCRATE3 R H REFFLD(AHRT# WMAHP) 3.0
- Attachments
-
- quotetest.txt
- (54.77 KiB) Downloaded 606 times
- David
- Profound Logic Staff Member
- Posts: 690
- Joined: Fri Jan 04, 2008 12:11 pm
- First Name: David
- Last Name: Russo
- Company Name: Profound Logic Software
- Contact:
Re: Linked auto-complete fields
One problem is the formatting of the "onchange" property value for the Group drop down box. You have it specified like this:
This is not what you want. The 'js:' prefix causes PUI to (at the time the screen is loaded) evaluate the value as a JS expression, and then use the result of the expression to populate the property. This means that applyProperty() is running just once at the time the screen is loaded and it's return value is used to set the "onchange" property at that time. Of course this return value is meaningless in the context of the "onchange" property, so this is why nothing happens when you change the drop down.
Use this instead:
When done this way, PUI will run the above code anytime the drop down is changed.
Obviously I can't test with your DB files, but I tried it this way:
1. I removed the database driven selection properties from the drop down and specified my own list using "choices" and "choice values" so that I'll have selections choices to try changing.
2. I ran the screen in Preview mode, specifying a value for the hidden output field and the drop down box.
3. When I change the selection in the drop down, the code (as adjusted above) does set the "selection criteria" of the "primary agency" box to include the value from the drop down and the output field.
Let me know how this works for you.
Code: Select all
js: applyProperty("TxbAgentNumber1", "field type", "textbox");
Use this instead:
Code: Select all
applyProperty("TxbAgentNumber1", "field type", "textbox");
Obviously I can't test with your DB files, but I tried it this way:
1. I removed the database driven selection properties from the drop down and specified my own list using "choices" and "choice values" so that I'll have selections choices to try changing.
2. I ran the screen in Preview mode, specifying a value for the hidden output field and the drop down box.
3. When I change the selection in the drop down, the code (as adjusted above) does set the "selection criteria" of the "primary agency" box to include the value from the drop down and the output field.
Let me know how this works for you.
-
- Profound User
- Posts: 27
- Joined: Tue Feb 07, 2012 11:29 am
- First Name: john
- Last Name: holsombach
- Company Name: stoneriver, inc.
- Contact:
Re: Linked auto-complete fields
I changed my applyproperty call and that appears to be working. I set up a text box with a value in it and i could tell that it was being redrawn (the font changed slightly).
However I still can't seem to get the new value from the dropdown, or even a regular text box.
For instance, i set up one text box with an onchange event to do the applyproperty to a second text box. The second text box has its value set to
js: " Fein = " + get("TxbFein")
When the screen loads, i see "Fein = 000000000"
When i change the fein text box, i see the font change slightly in the 2nd but it keeps the same value of "Fein = 000000000".
However I still can't seem to get the new value from the dropdown, or even a regular text box.
For instance, i set up one text box with an onchange event to do the applyproperty to a second text box. The second text box has its value set to
js: " Fein = " + get("TxbFein")
When the screen loads, i see "Fein = 000000000"
When i change the fein text box, i see the font change slightly in the 2nd but it keeps the same value of "Fein = 000000000".
Who is online
Users browsing this forum: No registered users and 0 guests