Skip to content

Error “System.ArgumentException: propertyName” raised when you try to use forms targeted to your custom class

Error “System.ArgumentException: propertyName” raised when you try to use forms targeted to your custom class published on 4 Comments on Error “System.ArgumentException: propertyName” raised when you try to use forms targeted to your custom class

You’ve created a new class based on any existing class and have added existing form (with or without modifications) for it. Then you was imported management pack to SCSM and have tried to use that form but console was crashed with exception. Error “System.ArgumentException: propertyName” was recorded in “Operations Manager” event log. Why this happened?

The reason is what the SCSM like a soldier: it executes the orders without discussions. And when you targeted you form to class SCSM load properties only for that class. But most of the form (especially for work items) use related classes like Related Configuration Items, Affected User, Assigned To use and so on.  And form try to access to the related class but SCSM doesn’t loaded them and that is the reason of the problem.

To avoid this you must target your form to type projection (or “Combination Class”, I use TP shortcut below) based on your class instead of class itself. In this case all related class will be loaded by SCSM and form can get properties from them.

To do that you must know target type of the form for your base class. You can do it by querying database but much more easily do that with PowerShell and SMLets.

Script below search form by class name and no matter what target type form are use: class itself or one of the type projections. Also script has a –ReturnTarget switch what allow to return target type property of the form. Please import the SMLets before use that script.

param([string]$className, [switch]$ReturnTarget)

$cl = Get-SCSMClass -Name "$className$"
$allIds = @{$cl.Id=$cl}

$tps = Get-SCSMTypeProjection | ? {$_.TargetType -eq $cl} | % { $allIds.Add($_.Id, $_)}

$form = Get-SCSMForm | ? { $allIds.Keys -contains $_.Target.Id}
    return $allIds[$form.Target.Id]
    return $form

For example you have created a new class based on “Service Request” class. Lets’ find the form what used for this class:
and target type for this form ( –ReturnTarget switch):

As you can see this form targeted to System.WorkItem.ServiceRequestProjection. You must copy XML declaration of this TP to our management pack and set this new TP as target for custom form. To do that you must know a management pack where founded type projection are stored. Almost all of the types in SCSM support GetManagementPack() method so you can use same script to get management pack:

.\Get-SCSMFormByClassName.ps1 "System.WorkItem.ServiceRequest" -ReturnTarget | % {$_.__base.GetManagementPack()}

Note:  SMLets hide the type’s object in __base property. Result:
This management pack area sealed so you can use only two ways to get XML code – query to database or use tools to dump management pack. I prefer the first way so here is a query to get XML code of the management pack:

USE ServiceManager
SELECT MPName,MPFriendlyName, CONVERT(xml, MPXML), MPIsSealed FROM ManagementPack
MPName = 'ServiceManager.ServiceRequest.Library'

This query return a XML data which can be displayed in SQL Management Studio. Now you must find a type projection declaration by searching “System.WorkItem.ServiceRequestProjection” substring. Copy declaration to your management pack and set Type property to your class and set new name for that TP (ID property):
And last step is a change Target property of your form to newly created TP.


%d bloggers like this: