+ Start a Discussion

2 Picklist fields, one setting the value of another

Is there anyway to do the following, possibly using S-Controls/Javascript?
I'd like to add a custom picklist field called 'Subtype' to the Task object and define the values of this field such that each value corresponds to a valid value of the (standard) 'Type' field.
Whichever value the user enters/selects for the 'Subtype' field would then automatically set the value of the 'Type' field.
For example a value of 'Normal visit' in Subtype would set the value of Type to 'Visit'.
Generally speaking there would be several 'Subtype' values corresponding to each 'Type' value.
Ideally, the Type field would not be displayed on the Task Page at all, but if it can't be removed then as long as it's value was set automatically - possibly with invalid combinations of values being disallowed by a Validation Rule - then this would be ok. What has to be avoided if possible (users have already been promised they won't have to do this) is for the user to have to enter both values.
Can this be done?
Thanks and regards
I had an idea to try and implement this requirement by creating an S-Control, placing it on the Task Page Layout and using the Javascript to attach event handlers to the 'Type' and 'Subtype' fields such that whenever the 'Subtype' value was changed, the 'Type' value was automatically set to the corresponding value.

This works fine when I try in in a standalone Javascript page created in Notepad:

<script type="text/javascript">

if (window.attachEvent) {
  window.attachEvent("onload", setListeners); // works in IE only
else {
  window.addEventListener("load", setListeners, false);

function box2Change() {
if (box2.value == "Normalbesuch" || 
    box2.value == "Spontanbesuch" ||
    box2.value == "Doppelbesuch" ||
    box2.value == "Fehlbesuch" ||
    box2.value == "Kongresskontakt" ||
    box2.value == "Essen mit Kunden") 
      box1.value = "Visit";
else if (box2.value == "Telefonkontakt") box1.value = "Phone call";
else if (box2.value == "Materialsendung") box1.value = "Shipment/giveaway without visit";
else alert("Invalid value!");


function setListeners() {
  box1 = document.getElementById("Box1");
  box2 = document.getElementById("Box2");
  if (window.attachEvent) {
    box2.attachEvent("onchange", box2Change);
  else {
    box2.addEventListener("change", box2Change, false);

This is a test page.
<select name="Box1" id="Box1">
<option value="Visit">Besuch</option>
<option value="Phone call">Telefonischer Kontakt</option>
<option value="Shipment/giveaway without visit">Versand/Abgabe ohne Besuch</option>
<br />
<select name="Box2" id="Box2"> 
<option value="Normalbesuch">Normalbesuch</option>
<option value="Spontanbesuch">Spontanbesuch</option>
<option value="Doppelbesuch">Doppelbesuch</option>
<option value="Fehlbesuch">Fehlbesuch</option>
<option value="Materialsendung">Materialsendung</option>
<option value="Telefonkontakt">Telefonkontakt</option>
<option value="Kongresskontakt">Kongresskontakt</option>
<option value="Essen mit Kunden">Essen mit Kunden</option>
<br />
<input type="submit" value="OK" />

 However, when I try and implement this through an S-Control, I run into the problem that the S-Control only runs when the page is shown in 'display' mode, but not in 'edit' mode. Obviously it's only in edit mode that I need this to work.

Is there any solution to this and/or an alternative means of achieving the same thing?

Thanks in advance


a dependent picklist won't work?

thanks for the suggestion.

However, as far as I can see, it's not possible to use the standard field 'Type' in a field dependency for the 'Activity' object.

When I try and create a new Field Dependency, the only fields it lets me use for the Controlling Field are Priority, Status, Visible in Self-Service, All Day Event, Private and my custom 'Subtype' field. For the Dependent Field the only field it lets me use is my custom Subtype field.

If I create another custom field 'Type2' and give it the same picklist values as Type then it lets me set up a dependent picklist. For example a 'Subtype' value of 'Normal Visit' is valid only for a 'Type' value of 'Visit'. By making this a required field on the Page Layout, I found that it results in the correct value being automatically set in the 'Type2' field whenever a value is set in the 'Subtype' field.

However I need the standard 'Type' field to contain the correct value (because it's used in a lot of Reports). Would there be any way I could automatically set 'Type' equal to 'Type2' in all instances? I don't think I can make 'Type' a formula field, can I?