Controlling the Display of Drop Down Options in Team Select Fields

Hints, Tips and Tricks

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

Controlling the Display of Drop Down Options in Team Select Fields

  • Comments 2
  • Likes

Many system entities such as Opportunities, Leads and Cases can be assigned to a Team.  Custom Entities can also have Teams assigned to them.  

For historic reasons the Team field in the database is called channelid.  

  • user_primarychannelid
  • oppo_channelid
  • case_channelid
  • lead_channelid

Team fields in custom entities normally follow the pattern xxxx_channelid.  So in a custom entity called project with the column prefix proj the Team field would be proj_channelid.

Within the system there is the option for a user to access the Team area from the Main Menu, and in this tab menu all the data is filtered by the context of the users primary team or their display Team.

Sage CRM Users can be associated with a Team, and can have additional Display Teams associated with them.

Note:  The users display teams are held in the table channel_link.

A customer may have a business requirement to limit the Options in a Team select field to only those teams that a user can normally seem in the Teams area of the Main Menu

This can be achieved for both entry and search screens by adding a create script against the Team field.

For example, in order to limit the options in the Team field in the Opportunity Search screen to only those of the users display teams so that the screen looks like this:

The oppo_channelid has to be added to the opportunitysearchbox screen and the following code can be added to the fields create script:


//create an array that contains users display team.
var strListTeams = CurrentUser.user_primarychannelid;
var recUserDisplayTeams = CRM.FindRecord("channel_link","chli_user_id="+CurrentUser.user_userid);
while (!recUserDisplayTeams.eof)
  strListTeams += ","+recUserDisplayTeams.chli_channel_id;
var arrayListDisplayTeams = strListTeams.split(",");

//create an array that contains all teams
var strAllTeams = "";
var recAllTeams = CRM.FindRecord("channel","");
while (!recAllTeams.eof)
  strAllTeams += recAllTeams.chan_channelid+",";
var arrayAllTeams = strAllTeams.split(",");
//create an array that contains the teams not in the users display list
var RemoveList = new Array();
z= 0;
for (x in arrayAllTeams)
if (!isThisTeamInDisplayList(arrayAllTeams[x],arrayListDisplayTeams))
RemoveList[z] = arrayAllTeams[x];
function isThisTeamInDisplayList(teamtocheck, arrayofdisplayteams)
flag = false;
for (count in arrayofdisplayteams)
if (teamtocheck == arrayofdisplayteams[count])
flag = true;
return flag;
//update Team drop down.
for (x in RemoveList)

The code above first builds an array that contains the user display teams including the primary team to which they are assigned.

Then the code builds an array that contains all the teams with the install of Sage CRM.

A third array is then built by comparing all the teams with the users display teams. This third array contains those teams not in the list of user Display Teams and the third array is then cycled through removing those teams from the field options, using the RemoveLookUp() method.