Creating a Basic List with the Web Class for Multiple Contexts

Less than one minute read time.

Below is some example code that shows how to create a simple list with the Web class for multiple contexts.

  • Company
  • Person
  • My CRM (Selected User)
  • Team


using Sage.CRM.Controls;
using Sage.CRM.WebObject;
 
namespace SA_Basic_1
{
    class OpposList : Web
    {
        public override void BuildContents()
        {
            GetTabs();
            AddContent(HTML.Form());
            List listOppos = new List("opportunitylist");
            
            int iDomKey = Keys[(int)Sage.KeyList.DominantKey];
            switch (iDomKey)
            {
                case 1:
                    listOppos.Filter = "oppo_primarycompanyid = " + GetContextInfo("company","comp_companyid");
                    break;
                case 2:
                    listOppos.Filter = "oppo_primarypersonid = " + GetContextInfo("person","pers_personid");
                    break;
                case 4:
                    listOppos.Filter = "oppo_assigneduserid = " + GetContextInfo("selecteduser","user_userid");
                    break;
                case 5:
                    listOppos.Filter = "oppo_channelid = " + GetContextInfo("user","user_primarychannelid");
                    break;
                default:
                    listOppos.Filter = "oppo_assigneduserid = " + GetContextInfo("user","user_userid");
                    break;
 
            }
            AddContent(listOppos);
        }
            
    }
}

Notes:

  • The Notification is displayed because of the standard behaviour of the GetTabs() method.
  • The code uses GetContextInfo("selecteduser","user_userid") to allow the user select a different user from the selection box in the topcontent area of the screen.