When using the SDK Entity template to quickly create a set of classes to support a custom entity in Sage CRM. It only mentions one records context within the constructor. These are the properties
FilterByField
FilterByContextId
The following code shows that a switch statement can be used to examine the dominant key and then provide the correct filter information. This would allow the class to be used in the My CRM menu, the Team menu as well as being called from the Company and Person contexts.
More about context and Keys can be found in the article "Long List of Key Values for Sage CRM".
Example C# Code
public class OpportunityList : ListPage
{
/* Constructor needs EntityName, ListName, IdField, FilterByField, FilterContext and ScreenName
*/
public OpportunityList()
: base("Opportunity", "OpportunityList", "OpportunityFilterBox")
{
int iDomKey = Keys[(int)Sage.KeyList.DominantKey];
switch (iDomKey)
{
case 1:
FilterByField = "oppo_primarycompanyid";
FilterByContextId = (int)Sage.KeyList.CompanyId;
break;
case 2:
FilterByField = "oppo_primarypersonid";
FilterByContextId = (int)Sage.KeyList.PersonId;
break;
case 4:
FilterByField = "oppo_assigneduserid";
FilterByContextId = (int)Sage.KeyList.UserId;
break;
case 5:
FilterByField = "oppo_channelid";
FilterByContextId = (int)Sage.KeyList.ChannelId;
break;
default:
FilterByField = "oppo_assigneduserid";
FilterByContextId = (int)Sage.KeyList.UserId;
break;
}
}
}