RonCK - Monday, March 23, 2009 4:38 PM:
Hi,
I am attempting to create a set of constraints on data that varies by item classification and ultimately places the data in a single field. Specifically, I would like to give my users a drop down list on the capacitor form that only lists capacitor values and a drop down list on the resistor form that only lists resistor values, but I would like both of those results to end up in the comp_value property.
My current understanding indicates that the way to do this is to have the user populate a cap_value from a cap_values list on the capacitor form and similarly on the resistor form and have a field event onChange Method that copies the value selected from the drop down to the undisplayed comp_value property.
This strikes me as it should be very easy, however, I'm having trouble figuring out where to get started. Does this method need to be client or server side? How do I determine that? How do I tell the Method that it is to operate on the currently open form?
thanks,
RonCK
RobMcAveney - Wednesday, March 25, 2009 2:35 AM:
Hi RonCK, and welcome. Can you clarify a bit? From your description it seems like you simply want comp_value to be compatible with the classification. So once the user chooses a class, the list of available values for comp_value is set? If this is correct, you may not need method code at all -- you could simply use a Filter List. This feature is comparable to what you see on many automotive web sites -- once you set the Make (Ford, Toyota, etc.), the dropdown for Model (Mustang, Camry, etc.) is updated with the correct values for that Make. In this case, once you set classification the dropdown for comp_value would be updated. Would that make sense in your case?
There's a good section on Filter Lists in the Administration training class. I would definitely recommend taking that if you haven't already. If Filter Lists aren't exactly what you're looking for then similar things can be done with method code, but I'd need more details to help you with that.
Regards -
Rob
RonCK - Wednesday, March 25, 2009 10:02 AM:
Hi Rob,
Thanks for the welcome. I can clarify. What you describe would work for us. Basically, I have extended the Item/Part/Component/ class to have a seperate branch for each type of electrical and mechanical part. We'd like to constrain entering data so that all users that enter new parts enter the information the same way. At least for electrical parts, I need three fields (comp_value, schem_symbol, and package) to be populated, but I'd like to draw the data from a seperate list for each Item class. Is there any examples or documents on filter lists available for perusal? I'm trying to get the database architecture complete this week and this decision will affect the number of properties I need to add greatly.
In the mean time, I've been working with someone more experienced with Java trying to try to get the method working. Here is the code we've come up with so far:
// name: SetCapValue
// purpose: copy the value from Capacitance Value to Component Value
// created: 09/03/23 by RonCK
//alert(document.getElementsByName('component_value')[0].value);
alert('Start');
var CapValue = document.getElementsByName('capacitance_value')[0].value;
//document.getElementsByName('component_value')[0].value = CapValue;
//alert(document.getElementsByName('component_value')[0].value);
alert('Here1');
var myInnov = new Innovator();
alert('Here2');
var tpart = myInnov.newItem("Part","get");
alert('Here3');
tpart.setProperty("component_value",CapValue);
alert('Here4');
tpart = tpart.apply;
alert('Here5');
document.getElementsByName('component_value').value = tpart.getProperty("component_value");
alert('Here6');
handleItemChange("component_value", document.getElementById("component_value").value);
This seems to get the data but it errors (Client side error) on the document.getElementsByName command in between Here5 & Here 6 and does not complete the copy.
Any ideas?
thanks,
RonCK
RobMcAveney - Thursday, March 26, 2009 1:20 AM:
Hi RonCK -
I wasn't able to find a directly applicable example on Filter Lists, so I'll just give you a step-by-step here:
- Create a new List item named FilterList. On the Filter Value tab (not the Value tab), enter the following and save
- Value=A1, Label=A1, Filter=/Part/Assembly, Sort Order=1
- Value=A2, Label=A2, Filter=/Part/Assembly, Sort Order=2
- Value=C1, Label=C1, Filter=/Part/Component, Sort Order=3
- Value=C2, Label=C2, Filter=/Part/Component, Sort Order=4
- Edit the Part ItemType, add a property with Name=fl, Label=FL, Data Type=Filter, Data Source=FilterList, Pattern=classification and save
- Edit the Part Form, click on the Unused Properties dropdown and choose the fl property. Place the new field in a open area of the Form and save.
- Create a new Part item and set the Type (classification) field to Assembly. Click on the FL dropdown -- you should see A1 and A2. Set the Type field to Component and click on the FL dropdown -- you should see C1 and C2.
I hope that gives you an idea of what you can do with Filter Lists. Let me know if this fits your needs. If not, I can certainly help more with the method approach.
Regards -
Rob