Working Client Side with User Select Lists

1 minute read time.



A customer had the need for a field on their company screen that works superficially like the highlighted section in this picture of the new communication screen.

Really what the customer wanted was to have a field that contains a list of user names. The user names need to get added to the list by the user picking them from a user selection box so that they don't have to remember the names.

This can be done by creating two fields, one as a user select and another as a text box.

Let's say these fields are

comp_demo (user select)
comp_usercollection (multiline text box)

We can use the onchange event of the user select field to put its value into the text box. The onchange would first get the value of what was in this box and then concatenate the new selection to the end.

Now a user selection box only returns the UserID not the name, so how can we use that to build a list of names?

In this case it is only the names of the users that the customer wants. Because of this we can certainly use the two fields approach as although the select list value is the userid, nonetheless the prompt associated with the option contains the name. We can then have that written into the multiline text box.

Select lists like the user list are made up of Options.

The clientside Option object in JScript has two relevant properties. The 'value' and the 'text'.

The 'value' contains, well, the Value

The 'text' contains the prompt.

Also with selection lists you may have to faff around with the options[] and selectIndex properties of the 'select' to get the right thing. The following code can then be used in the user select field

var intOption = document.EntryForm.comp_demo.selectedIndex;
var strPrompt = document.EntryForm.comp_demo.options[intOption].text + ', ';
//alert(intOption);
//alert(strPrompt);
document.EntryForm.comp_usercollection.value += strPrompt;
  • Hi Jeff,

    Can we restrict oppo_assigneduserid field based on team or territory . For example user A1,A2,A3 belongs to Showroom sales team and user B1,B2,B3 belongs to Direct sales team . While assigning an opportunity if we select Showroom sales team , then the assigned to user field should show only A1, A2 and A3.

    Same is the case with territory. If we assign an opportunity to a specific terrtitory , only user in that territory should appear in the assigned to user field.

    This has become one of the common requirement for all clients where the number of users are above 25-30. The user selection field shows all the users , irrespective of whether they belong to a specific team or whether they have access to see opportunity ,leads of specific territory. For example - User A1 may not have access to create or view opportunity in North territory. But while assigining the opprtunity , system permits assignment to user A1.