---
title: "setCalculationRule"
slug: "api/basket/operations/setcalculationrule"
sidebar:
  order: 476.1
---

## Synopsis

```text
void setCalculationRule(SessionId sessionId,
    BItemId[] itemIds,
    string ppName,
    string condType,
    int counter,
    CalculationRule calcRule,
    CondGroupSelectionOptions? options)
throws BasketServiceFault;
```

See also: [`SessionId`](/pCon/configuratorOnline/specs/api/session/types/sessionid), [`BItemId`](/pCon/configuratorOnline/specs/api/basket/types/bitemid), [`BasketServiceFault`](/pCon/configuratorOnline/specs/api/basket/faults/basketservicefault)

Sets the calculation rule of an item or header condition. Calculation selection and condition selection by type and counter work as for [setConditionAmount](/pCon/configuratorOnline/specs/api/basket/operations/setconditionamount). Use the Null-ID to select a header condition. The item IDs and [CondGroupSelectionOptions](/pCon/configuratorOnline/specs/api/basket/types/condgroupselectionoptions) select an item calculation or a temporary group calculation. An empty ppName is allowed if the basket uses only one pricing procedure; counter may be -1 if there is only one condition of the specified type.

The operation fails if the condition is not editable under its condition type's edit mode (and, where applicable, the presence of a condition record), if its calculation rule is not editable, or if calcRule is not among the condition type's allowed rules. Ordinary non-header group conditions never have editable calculation rules.

For an item condition whose explicitly specified rule already equals calcRule, the operation has no further effect. Otherwise it sets the rule, the amount and, if required, the quantity relation. If the new rule equals the previously effective rule, the server attempts to preserve the amount and quantity relation. If the rule differs or those values cannot be obtained, it uses defaults: zero percent for Percent, or zero in document currency for other rules. Quantity uses the sales unit size as quantity relation; GrossWeight, NetWeight and Volume use a value of one with the unit reported for one sales unit. Fallback quantities are 1 C62, 1 KGM or 1 MTQ, respectively. Header conditions behave similarly but have no quantity relation.

For a group of item conditions, including group and set-article calculations, the server first checks that the rule is allowed and every grouped condition permits editing. It then sets each item condition; subsequent individual errors are written to the session log rather than aborting the operation.

See also: [CalculationRule](/pCon/configuratorOnline/specs/api/basket/types/calculationrule), [ConditionType](/pCon/configuratorOnline/specs/api/basket/types/conditiontype), [CalculationLine](/pCon/configuratorOnline/specs/api/basket/types/calculationline), [resetCalculationRule](/pCon/configuratorOnline/specs/api/basket/operations/resetcalculationrule).
