As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.
Join the TIBCO Community TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.
From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
Request access to the private WebFOCUS User Group (login required) to network with fellow members.
Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.
Okay, I'm struggling through a Maintain application -- the comboboxes are giving me fits as they just don't seem intuitive to me. But then again, sometimes I'm just dense...
I have a table that I want to update in a MS SQL Server database. The table has a couple of ID columns that are foreign keys to other tables. Naturally I want to populate that column with an ID, but want to provide the user with a combobox (dropdown) of the possible choices.
I've created the form and added the comboboxes. On the list source, I've picked "From a variable" and pointed it to a stack that represents the FK table. The column I've picked is the "name" column so the user sees the appropriate names in the combobox. In the bind the selection result, I picked the stack that represents the table I'm updating and picked the ID column from that stack that FKs to the other "name" table. I've also picked to send the result as "value".
Here's the dilemma, when I'm adding a new record, all seems to work fine. But when I want to update an existing record, the dropdown does not represent the current value of that record when the form opens. In other words, I could have picked the 4th value in the combobox, but when the form opens, it always shows the first item in the combobox. It will still update correctly, it's just that it doesn't show correctly upon opening of an existing record.
Forgive the frustration, but is there another "hoop" that I have to jump through now to make this select the existing value?
Production: 7.6.6 WF Server  <=>  7.6.6 WF Client  <=>  7.6.6 Dev Studio Testing: <none> Using MRE & BID.  Connected to MS SQL Server 2005 Output Types: HTML, Excel, PDF
The item you want to be highlighted/selected in the combo box needs to be set.
Unfortunately, there is no easy way around this.
Run a case that loops through the stack until the value in the field in the stack matches your required value, that is then the FocIndex to set.
Goes something like:
myStack.FocIndex= search(IncomingFieldValue);
Case search takes searchString/a12 returns Index/i6; Declare cntr/i6=1; Index=-1; repeat myStack.FocCount if (searchString eq myStack(cntr).searchField) then Index = cntr; if index gt -1 goto exitrepeat; endrepeat cntr=cntr+1; EndCase
Hope that helps.
Alan. WF 7.705/8.007
Posts: 1451 | Location: Portugal | Registered: February 07, 2007
Using your example, I think I got it working. Mine was a little different since I was actually searching for the ID in the stack, but the concept was the same.
I ended up having to code 3 different search functions because I had 3 different comboboxes (from 3 different stacks). My OOP brain makes me think there should be a way to do it in one function, but that would mean I had to pass the stackname and searchfield as parameters to the function also -- and I couldn't find any obvious datatypes for that...
If you have any suggestions, that would be great -- but I appear to be working again thanks to your help!
[rant]It really is unfortunate though to have to jump through that extra hoop just to make this happen though -- for something that seems as basic as a dropdown list[/rant]
Production: 7.6.6 WF Server  <=>  7.6.6 WF Client  <=>  7.6.6 Dev Studio Testing: <none> Using MRE & BID.  Connected to MS SQL Server 2005 Output Types: HTML, Excel, PDF
I realize this was over a year ago, but do you mind posting your solution? I've run into the same issue and am struggling w/the proper syntax to locate the ID.
I agree there should be a much easier way to accomplish this common thing.
Thanks,
quote:
Originally posted by Trav: Using your example, I think I got it working. Mine was a little different since I was actually searching for the ID in the stack, but the concept was the same.
I ended up having to code 3 different search functions because I had 3 different comboboxes (from 3 different stacks). My OOP brain makes me think there should be a way to do it in one function, but that would mean I had to pass the stackname and searchfield as parameters to the function also -- and I couldn't find any obvious datatypes for that...
If you have any suggestions, that would be great -- but I appear to be working again thanks to your help!
Kelly WF 7.6.6, Win 2K3 SP2, Tomcat
Posts: 19 | Location: SLC, UT | Registered: January 19, 2007
Kelly We had tried methods of setting the SelectedItem value to the desired selection, but that always seemed to break something else. The BEST way to preset a List or Combo box is with this code:
Compute I/I2=1; Repeat ComboBoxStack2.Foccount If ComboBoxStack2(I).field = ComboBoxStack1().field then Begin Compute ComboBoxStack2.Focindex = I; Goto ExitRepeat Endbegin Compute I=I+1; Endrepeat
Here, ComboBoxStack1().field is the selection from the first box that determines what is displayed in the second. If there is a chance that the value is not in the second stack, then you can set a flag and issue a message or just do nothing.
Mark
Posts: 663 | Location: New York | Registered: May 08, 2003
Thank you, Mark. I was able to get it working great.
Much appreciated!
quote:
Originally posted by Maintain Wizard: Kelly We had tried methods of setting the SelectedItem value to the desired selection, but that always seemed to break something else. The BEST way to preset a List or Combo box is with this code:
Compute I/I2=1; Repeat ComboBoxStack2.Foccount If ComboBoxStack2(I).field = ComboBoxStack1().field then Begin Compute ComboBoxStack2.Focindex = I; Goto ExitRepeat Endbegin Compute I=I+1; Endrepeat
Here, ComboBoxStack1().field is the selection from the first box that determines what is displayed in the second. If there is a chance that the value is not in the second stack, then you can set a flag and issue a message or just do nothing.
Mark
Kelly WF 7.6.6, Win 2K3 SP2, Tomcat
Posts: 19 | Location: SLC, UT | Registered: January 19, 2007
If there is a chance that the value is not in the second stack, then you can set a flag and issue a message or just do nothing.
I like to use something like the following code to take care of that possibility:
Repeat While (I NE 0) I=stkCombo.Foccount; Compute stkCombo.Focindex = I ; If stkCombo(I).Field EQ stkDatabase().Field Then Goto Exitrepeat; Endrepeat I=I-1;
In addition I make sure that I have a dummy item ( such as 'Unknown) as the first member/record in the stack. This way the validation Javascript can see if the user made a selection, and if the database doesn't match any of the values in the combo box stack, it displays a meaningful value, instead of the erroneous last item.
BTW What do you call stack rows ? Rows, records, items. elements ?? I tend to use 'item', but not sure if I'm communicating well...