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}
if($ReturnTarget)
{
    return $allIds[$form.Target.Id]
}
else
{
    return $form
}

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

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:
image
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
where
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):
image
And last step is a change Target property of your form to newly created TP.

Share

4 Comments

Hello

Thank you for this KA.
But not everything is go as you wrote in article. After importing customized pack (the same class was customized as you describe) I tried to use it for service offering creation and saw exception “propertyName” like in this article.

I did all step and have some another result as you showed:

1. I got two different forms – I don’t know why

2. I got error on step “GetManagementPack() method”

Could you help with this?
Screenshot:
[IMG]http://i50.tinypic.com/2z3rqys.jpg[/IMG]

Also it’s interesting why this exception appears not for all customized classes ?

Thank you

[…] you will recieve this error after opening the form : System.ArgumentException: propertyName See http://blog.scsmsolutions.com/2012/05/propertyname-error-on-form-targeted-to-custom-class/ for additional information. The different components can be copied from the default service […]

I know this is an old post, but I’m struggling with this very issue. I have inherited from service request, added three new classes, then created a custom SR form. I have done this successfully before with an employee onboarding form and it all works.

The difference with this form is that there are no TypeProjections present in the XML when I go to edit it. So I followed your guide and put them in from the default service request form. However I’m struggling with the Type Projection ID and the Type name – how do I name them? I tried a couple of scenarios for names, but only one let me open the MP in the authoring tool without it failing

“Service Manager Authoring Tool
XSD verification failed for the management pack [Line: 0, Position : 0]”

I have added them after the EnumerationTypes element so it should be fine in theory.

Leave a Reply to Dmytro Cancel reply

%d bloggers like this: