Working Client Side with User Select Lists

Hints, Tips and Tricks

Technical Hints Tips and Tricks that cover customization and development using Sage CRM. API usage and coding are covered.

Working Client Side with User Select Lists

  • Comments 2
  • Likes



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;
Comments
  • 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.  

  • Jeff,

    How can we build a Select list that works similiar to the User Select List for Scheduling only for a custom Select List?  For example say a custom secondary entity with a list of values that we want to appear in the list search box and we want to be able to add selected values to the Main box. The reason we are trying to do this is because from a user standpoint the MultiSelect box has an inert flaw in that most users won't know to use Ctrl + when they are selecting values and could potentially cause problems when editing existing entries if they don't remember what was already selected and forget to hit ctrl before selecting a new value.

    Also, from the example above I don't see how you would create the Add/Remove buttons to acompany the list.