Best way to get the class for a ManagementPackObjectTemplate?
-
Wednesday, June 22, 2011 1:56 AMModerator
Hi,
I'm wanting to list templates in a drop-down that target the incident class and have certain properties included in the template.
I've done both of these but the only way I've found to check the class of the mpot is to check the typeid to see if it matches my type projection Id or use GetType() and check something under that.
I was wondering what the preferred method of doing this was? There must be a better way than what I'm using...
Thanks,
Rob
All Replies
-
Wednesday, June 22, 2011 3:09 AMModerator
I settled for this, but it looks a little long-winded to me:
foreach (ManagementPackObjectTemplateProperty mpotp in ilistmpotp)
{
if (mpotp.Path.IndexOf("/Impact$") != -1) bImpact = true;
if (mpotp.Path.IndexOf("/Urgency$") != -1) bUrgency = true;
if (mpotp.Path.IndexOf("System.WorkItem.Incident") != -1) bIncident = true;
if (mpotp.Path.IndexOf("System.Notification.Template") != -1) bTemplate = false;
}if (bImpact && bUrgency && bIncident && bTemplate)
{
bList = true;
} -
Wednesday, June 22, 2011 7:43 AMModeratorTypeId property is a target class ID of template. Maybe this can help.
http://opsmgr.ru -
Wednesday, June 22, 2011 7:30 PMModeratorYeah, I was originally using the TypeId but the Id of the type projection varies from installation to installation, but, if I get the ManagementPackTypeProjection from TypeID.Id I can check that to see what it is and possibly use that, I'll check that out, thanks.
-
Wednesday, June 22, 2011 8:06 PMModerator
This does it:
//Check class
ManagementPackTypeProjection mptpType = null;
try
{
mptpType = emg.EntityTypes.GetTypeProjection(mpot.TypeID.Id);
if (mptpType.TargetType == mpcIncident) bIsIncident = true;
}
catch
{
}- Marked As Answer by Rob.FordMVP, Moderator Wednesday, June 22, 2011 9:30 PM

