Share via


SPHealthRulesList.AddItem method (SPHealthAnalysisRule)

Creates a list item and a timer job for the specified instance of a rule.

Namespace:  Microsoft.SharePoint.Administration.Health
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'Declaration
Public Function AddItem ( _
    rule As SPHealthAnalysisRule _
) As SPListItem
'Usage
Dim instance As SPHealthRulesList
Dim rule As SPHealthAnalysisRule
Dim returnValue As SPListItem

returnValue = instance.AddItem(rule)
public SPListItem AddItem(
    SPHealthAnalysisRule rule
)

Parameters

Return value

Type: Microsoft.SharePoint.SPListItem
A list item for the instance of the rule.

Exceptions

Exception Condition
Exception

A list item for the rule already exists.

ArgumentNullException

The argument to the rule parameter is a null reference (Nothing in Visual Basic).

ArgumentOutOfRangeException

The value of the rule's Category property cannot be SPHealthCheckErrorLevel.Success or SPHealthCheckErrorLevel.RuleExecutionFailure.

MissingMemberException

The value of the rule's AutomaticExecutionParameters property is a null reference (Nothing in Visual Basic).

Remarks

This overload of the AddItem method throws an exception if the list already has an item for the rule that you want to add. To overwrite an existing list item with a new version of the rule, call the AddItem(SPHealthAnalysisRule, Boolean) method.

See also

Reference

SPHealthRulesList class

SPHealthRulesList members

AddItem overload

Microsoft.SharePoint.Administration.Health namespace