🔍 Code Extractor

class QueryPropertyValue

Maturity: 48

A class representing a typed property value container for SharePoint Client Search Query operations, where only one property type should be set at a time based on the QueryPropertyValueTypeIndex.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/search/query/property_value.py
Lines:
4 - 35
Complexity:
simple

Purpose

QueryPropertyValue is a specialized ClientValue class designed to store values of predefined types for SharePoint search queries. It acts as a discriminated union where exactly one of the value properties (BoolVal, IntVal, StrArray, or StrVal) should be populated based on the QueryPropertyValueTypeIndex (1=string, 2=int, 3=bool, 4=string array). This class is used in the Microsoft SharePoint Client Search Query API to represent typed property values in search operations.

Source Code

class QueryPropertyValue(ClientValue):
    """This object is used to store values of predefined types. The object MUST have a value set for only
    one of the property."""

    def __init__(
        self,
        bool_val=None,
        int_val=None,
        str_array=None,
        str_val=None,
        query_property_value_type_index=None,
    ):
        """
        :param bool bool_val: Specifies any arbitrary value of type CSOM Boolean. This property MUST have a value only
            if QueryPropertyValueTypeIndex is set to 3.
        :param int int_val: Specifies any arbitrary value of type CSOM Int32. This property MUST have a value only
            if QueryPropertyValueTypeIndex is set to 2.
        :param int query_property_value_type_index: Specifies the type of data stored in this object.
        :param list[str] str_array: Specifies any arbitrary value of type CSOM array. This property MUST have a
             value only if QueryPropertyValueTypeIndex is set to 4.
        :param str str_val: Specifies any arbitrary value of type CSOM String. This property MUST have a value
             only if QueryPropertyValueTypeIndex is set to 1.
        """
        self.BoolVal = bool_val
        self.IntVal = int_val
        self.StrArray = str_array
        self.StrVal = str_val
        self.QueryPropertyValueTypeIndex = query_property_value_type_index

    @property
    def entity_type_name(self):
        return "Microsoft.SharePoint.Client.Search.Query.QueryPropertyValue"

Parameters

Name Type Default Kind
bases ClientValue -

Parameter Details

bool_val: Optional boolean value to store. Should only be set when QueryPropertyValueTypeIndex is 3. Represents any arbitrary CSOM Boolean value.

int_val: Optional integer value to store. Should only be set when QueryPropertyValueTypeIndex is 2. Represents any arbitrary CSOM Int32 value.

str_array: Optional list of strings to store. Should only be set when QueryPropertyValueTypeIndex is 4. Represents any arbitrary CSOM array value.

str_val: Optional string value to store. Should only be set when QueryPropertyValueTypeIndex is 1. Represents any arbitrary CSOM String value.

query_property_value_type_index: Integer indicating which type of data is stored in this object. Valid values: 1 (string), 2 (integer), 3 (boolean), 4 (string array). This determines which property should have a value.

Return Value

Instantiation returns a QueryPropertyValue object that inherits from ClientValue. The object contains five instance attributes (BoolVal, IntVal, StrArray, StrVal, QueryPropertyValueTypeIndex) and provides an entity_type_name property that returns the fully qualified SharePoint type name 'Microsoft.SharePoint.Client.Search.Query.QueryPropertyValue'.

Class Interface

Methods

__init__(self, bool_val=None, int_val=None, str_array=None, str_val=None, query_property_value_type_index=None)

Purpose: Initializes a new QueryPropertyValue instance with optional typed values

Parameters:

  • bool_val: Optional boolean value (use when query_property_value_type_index=3)
  • int_val: Optional integer value (use when query_property_value_type_index=2)
  • str_array: Optional list of strings (use when query_property_value_type_index=4)
  • str_val: Optional string value (use when query_property_value_type_index=1)
  • query_property_value_type_index: Integer indicating the type of value stored (1-4)

Returns: None (constructor)

@property entity_type_name(self) -> str property

Purpose: Returns the fully qualified SharePoint entity type name for this class

Returns: String 'Microsoft.SharePoint.Client.Search.Query.QueryPropertyValue' representing the SharePoint CSOM type

Attributes

Name Type Description Scope
BoolVal bool or None Stores a boolean value when QueryPropertyValueTypeIndex is 3 instance
IntVal int or None Stores an integer value when QueryPropertyValueTypeIndex is 2 instance
StrArray list[str] or None Stores a list of strings when QueryPropertyValueTypeIndex is 4 instance
StrVal str or None Stores a string value when QueryPropertyValueTypeIndex is 1 instance
QueryPropertyValueTypeIndex int or None Indicates which type of value is stored: 1=string, 2=integer, 3=boolean, 4=string array instance

Dependencies

  • office365.runtime.client_value

Required Imports

from office365.runtime.client_value import ClientValue

Usage Example

# Example 1: Creating a string property value
from office365.runtime.client_value import ClientValue

class QueryPropertyValue(ClientValue):
    def __init__(self, bool_val=None, int_val=None, str_array=None, str_val=None, query_property_value_type_index=None):
        self.BoolVal = bool_val
        self.IntVal = int_val
        self.StrArray = str_array
        self.StrVal = str_val
        self.QueryPropertyValueTypeIndex = query_property_value_type_index
    
    @property
    def entity_type_name(self):
        return "Microsoft.SharePoint.Client.Search.Query.QueryPropertyValue"

# Create a string value
string_prop = QueryPropertyValue(str_val="example", query_property_value_type_index=1)
print(string_prop.StrVal)  # Output: example
print(string_prop.entity_type_name)  # Output: Microsoft.SharePoint.Client.Search.Query.QueryPropertyValue

# Create an integer value
int_prop = QueryPropertyValue(int_val=42, query_property_value_type_index=2)
print(int_prop.IntVal)  # Output: 42

# Create a boolean value
bool_prop = QueryPropertyValue(bool_val=True, query_property_value_type_index=3)
print(bool_prop.BoolVal)  # Output: True

# Create a string array value
array_prop = QueryPropertyValue(str_array=["item1", "item2"], query_property_value_type_index=4)
print(array_prop.StrArray)  # Output: ['item1', 'item2']

Best Practices

  • Only set one value property at a time based on the QueryPropertyValueTypeIndex to maintain data integrity
  • Always set QueryPropertyValueTypeIndex to match the type of value being stored (1=string, 2=int, 3=bool, 4=string array)
  • Leave other value properties as None when setting a specific type to avoid confusion
  • Use the entity_type_name property when serializing for SharePoint API calls
  • This class follows the CSOM (Client-Side Object Model) specification for SharePoint, so adhere to those type constraints
  • The class is immutable after construction in typical usage - create new instances rather than modifying existing ones
  • This class is typically used as part of larger SharePoint search query operations, not standalone

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class QueryProperty 79.3% similar

    A class representing a name-value pair for storing additional or custom properties for SharePoint search queries.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/search/query/property.py
  • class SearchQuery 66.8% similar

    Represents a search query object that encapsulates search terms and optional query templates for SharePoint/Office365 search operations.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/search/query.py
  • class PopularTenantQuery 65.6% similar

    A client value class representing a popular tenant query in Microsoft SharePoint Search API, used to interact with SharePoint's search query functionality for popular tenant-level queries.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/search/query/popular_tenant_query.py
  • class QuerySuggestionQuery 64.1% similar

    A client value class representing a query suggestion query for SharePoint search operations.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/search/query/suggestion_results.py
  • class PropertyValues 62.6% similar

    A class representing a collection of name/value pairs for CSOM (Client-Side Object Model) expando fields in SharePoint.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/types/property_values.py
← Back to Browse