1
votes

I have a form that has several fields that update based on combo boxes. The first combo box uses @DbColumn to pull the first column in a view. The second combo box pulls the second column in the same view based on the the selection of the first combo box. That works fine. The issue is; I have several succeeding computed fields that use the selection from the second combo box to pull from the same view's, succeeding columns. Those computed fields are not working. I thought I could merely use an @DbLookup command in Javascript to call the values from the view but it is not working.
Here is the javascript code for the first combo box (pretty simple):

@DbColumn(@DbName(), "PLBV", 1)

Here is the second combo box code:

var vendor = getComponent("POVendor").getValue();
var items = @DbLookup(@DbName(), "PLBV", vendor, 2);
if (@IsError(items))
return "Please select a Vendor first";
else
return items;

Both of these routines work exactly as I want. Here is the issue. I have three more fields that should be populated based on the value of the second combobox. It doesn't work. I'll give you the code but it's really basic.

var item = document1.getItemValue("Item_1");
var cost = @DbLookup(@DbName(), "PLBV", item, 3);

return cost;

This code returns a blank value (nothing shows up in the field). What am I doing wrong?

2

2 Answers

2
votes

If you are trying to access the item before the document has been saved then you will need to use the following code:

var item = getComponent("Item_1").getValue();
var cost = @DbLookup(@DbName(), "PLBV", item, 3);

You might need to use getSubmittedValue() rather than getValue() depending upon the validation settings of the document.

Hope this helps.

Matt

0
votes

The problem stemed from me trying to call the value of a column from the same view I populated the second combo Box. That view has the first column categorized by the Vendor Name. The second column (the column I used to populate the second combo box) was a list of products offered by that vendor. That part worked fine. However; when I tried to call the value of the third columnm from the same view based on the value of the second combo box (the product), I got nothing.
I have a separate view that is a complete list of products without being categorized by the vendor that offers the product. I called colunms from that view based on the product name from the second combo box & all of my computed fields worked. Now my only issue is going to be, what happens when two different vendors use the same product name for two different products? I'll cross that bridge when I come to it. Thanks for all the help from everyone. It may not have solved the surfase issue but it gave me a much more in-depth understanding of what goes on behind the scenes.