Integrated Application Platform › Forums › General › Id control keys error
- This topic has 6 replies, 3 voices, and was last updated 8 years, 8 months ago by amckinlay.
September 3, 2014 at 2:47 pm #788
I got an error when use IdControl in following situation.
1) I have a table called itemUOM which contains two fields: itemUOM_ItemNo, itemUOM_UOMCode. Same item could be packed up in different UOMs. These two fields are combined to be the only key at the same time. itemUOM_ItemNo is linked to the master item table which works just fine.
2) I have another table called purchLine which has two fields: purchLine_No(linked to item master table) and purchLine_UOMCode(linked to the first table).
3) After the user selected the item no., i would like the user to be able to select the purchLine_UOMCode from a list showing records from first table filtered by the item no. which is purchLine_No in this case.
I somehow couldn’t make it work with KeyControl or IdControl. I tried the ‘whereField’ parameter as described in the user manual:
"itemUOM rename itemUOM_ItemNo to purchLine_No"
but it complains about the keys, error “KeyListView: no usable keys”. After inspecting the query during runtime, the query passed in seems to be fine.
Is it because both controls are designed for tables which have only one field in the primary key?
Any idea is appreciated.September 3, 2014 at 9:12 pm #1095j_fergusonModerator
IdControl and KeyControl do not currently work with composite keys, sorry.
You should be getting the same error even without the whereField specified.
An ugly work-around would be to manually build a single key value for each record using a combination of the two field values (and store it in a separate field and make that single field the key).September 3, 2014 at 10:16 pm #1096
If the number of choices is reasonably small, you could use ChooseListControl with the listField option (see the docs)
The listField rule can do a query to get the relevant choices.September 4, 2014 at 4:59 am #1097
hi both, thanks indeed for your suggestions.
j_ferguson: your workaround could indeed be implemented, but i am very much keen to find a more simplified solution.
andrew: I have already used your suggestion in a different case. The disadvantage is that you end up seeing only one field without knowing what’s inside of other fields which provide more relevant information to make the selection. Also, the possibility of modifying the original table through ‘access’ button is gone.
I would like to modify KeyControl or create a different control my own to do following:
Modifying the whereField or restrictions to be an object #((‘sourcefield1′,’=’,currenctfield1),(‘sourcefield2′,’>’,currenctfield2),…). sourcefield is passed in as field name of the source table which will be filtered on and currentfield is passed as filter value from current table. This way, the rename command in the query could also be avoided.
I also would like to deactivate key checks because i don’t see them too necessary here, except providing sorting and record identification which is not my concern in most of the cases.
Is that possible?
thanksSeptember 4, 2014 at 2:09 pm #1098
You need some kind of “key” to uniquely identify a record so when it is picked from the list you know which one is being picked.
You might want to create your own control, rather than modifying KeyControl, since it is probably more complex than you need. A lot of options have been added over time. Of course, you can use KeyControl as a guide.September 7, 2014 at 4:46 am #1099
thanks for the information andrew. I have added this feature into a copy of the standard KeyControl. It works well for me. Although, maybe I shouldn’t have gone that way as it turned out to be quite complex, involving quite a few other standard objects. I just cant help myself :).
Now, I still have a small issue. When the item no. changes, the existing unit of measure code assigned for previous item no. could no longer be valid for the new item no. How could I make UOM code show as red? When i type invalid data in this control, system shows this field as red, preventing user from saving the record. I want system to do the same when it becomes invalid due to item no. changes.
ThanksSeptember 8, 2014 at 3:04 pm #1100
One way is to add an observer to the record control
and use that to set whether the control is valid.
- You must be logged in to reply to this topic.