🔍 Code Extractor

class FieldUrlValue

Maturity: 45

A class representing a SharePoint FieldURL value, which encapsulates both a URL and its description for hyperlink fields.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/fields/url_value.py
Lines:
4 - 19
Complexity:
simple

Purpose

This class is used to represent hyperlink field values in SharePoint, combining a URL with an optional description. It inherits from ClientValue and is specifically designed for working with SharePoint's FieldURL field type, which stores hyperlinks with associated display text. The class enforces SharePoint's constraints that both URL and description must be 255 characters or less.

Source Code

class FieldUrlValue(ClientValue):
    """Specifies the hyperlink and the description values for FieldURL."""

    def __init__(self, url=None, description=None):
        """
        :param str url: Specifies the URI. Its length MUST be equal to or less than 255. It MUST be one
             of the following: NULL, empty, an absolute URL, or a server-relative URL.
        :param str description: Specifies the description for the URI. Its length MUST be equal to or less than 255.
        """
        super(FieldUrlValue, self).__init__()
        self.Url = url
        self.Description = description

    @property
    def entity_type_name(self):
        return "SP.FieldUrlValue"

Parameters

Name Type Default Kind
bases ClientValue -

Parameter Details

url: The hyperlink URI string. Must be 255 characters or less. Can be NULL, empty, an absolute URL (e.g., 'https://example.com'), or a server-relative URL (e.g., '/sites/mysite'). This represents the actual destination of the hyperlink.

description: The display text or description for the hyperlink. Must be 255 characters or less. This is the text that users will see as the clickable link text in SharePoint.

Return Value

Instantiation returns a FieldUrlValue object that encapsulates a URL and description pair. The object can be used to set or retrieve hyperlink field values in SharePoint operations. The entity_type_name property returns the string 'SP.FieldUrlValue', which identifies this object type in SharePoint's client object model.

Class Interface

Methods

__init__(self, url=None, description=None)

Purpose: Initializes a new FieldUrlValue instance with a URL and optional description

Parameters:

  • url: The hyperlink URI string (max 255 chars), can be NULL, empty, absolute URL, or server-relative URL
  • description: The display text for the hyperlink (max 255 chars)

Returns: None (constructor)

@property entity_type_name(self) -> str property

Purpose: Returns the SharePoint entity type name for this value object

Returns: The string 'SP.FieldUrlValue' which identifies this object type in SharePoint's client object model

Attributes

Name Type Description Scope
Url str or None Stores the hyperlink URI. Must be 255 characters or less. Can be NULL, empty, an absolute URL, or a server-relative URL. instance
Description str or None Stores the description/display text for the hyperlink. Must be 255 characters or less. instance

Dependencies

  • office365

Required Imports

from office365.runtime.client_value import ClientValue

Usage Example

from office365.runtime.client_value import ClientValue
from office365.sharepoint.fields.field_url_value import FieldUrlValue

# Create a hyperlink with both URL and description
url_value = FieldUrlValue(
    url='https://www.example.com',
    description='Example Website'
)

# Access the properties
print(url_value.Url)  # Output: https://www.example.com
print(url_value.Description)  # Output: Example Website
print(url_value.entity_type_name)  # Output: SP.FieldUrlValue

# Create with only URL
url_only = FieldUrlValue(url='https://www.microsoft.com')

# Create with server-relative URL
relative_url = FieldUrlValue(
    url='/sites/mysite/documents',
    description='Documents Library'
)

Best Practices

  • Ensure URL and description strings do not exceed 255 characters to comply with SharePoint's field constraints
  • Use absolute URLs (starting with http:// or https://) for external links and server-relative URLs (starting with /) for internal SharePoint resources
  • The Description parameter is optional but recommended for better user experience as it provides context for the link
  • This class is typically used when setting values for SharePoint list items with FieldURL column types
  • The entity_type_name property should not be modified as it identifies the object type in SharePoint's client object model
  • Instantiate a new FieldUrlValue object each time you need to set a hyperlink field value rather than reusing instances

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class FieldUrl 77.3% similar

    A specialized Field class that represents a SharePoint field containing a URL value.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/fields/url.py
  • class FieldLookupValue 70.4% similar

    Represents a lookup field value in SharePoint, encapsulating both the ID of the referenced list item and its display value.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/fields/lookup_value.py
  • class SocialLink 69.0% similar

    SocialLink is a class that represents a social media or web link with a URI and text representation, used to define the location of a website in SharePoint Social contexts.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/social/link.py
  • class ImageFieldValue 65.3% similar

    A class representing an image field value in SharePoint/Office365, inheriting from ClientValue to store metadata about an image including its URL, type, filename, and associated field information.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/fields/image_value.py
  • class FieldGeolocationValue 65.2% similar

    Represents a geolocation field value in SharePoint with latitude, longitude, and optional altitude coordinates.

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