Share via


SPHealthRulesList.AddItem method (SPHealthAnalysisRule, Boolean)

Creates a list item and a timer job for the specified instance of a rule, optionally overwriting an existing list item for the rule.

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

Syntax

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

returnValue = instance.AddItem(rule, overwrite)
public SPListItem AddItem(
    SPHealthAnalysisRule rule,
    bool overwrite
)

Parameters

  • overwrite
    Type: System.Boolean

    true to overwrite an existing list item for the rule; otherwise false.

Return value

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

Exceptions

Exception Condition
Exception

The argument to the overwrite parameter is false and 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

If you pass true as the argument to the overwrite parameter, and a list item for the rule already exists, all fields of the list item are overwritten. This behavior is useful, for example, if you need to change the default schedule of a rule.

See also

Reference

SPHealthRulesList class

SPHealthRulesList members

AddItem overload

Microsoft.SharePoint.Administration.Health namespace

Version