def get_by_title(self, title): """Returns the first fields object in the collection based on the title of the specified fields. :type title: str """ return Field(self.context, ResourcePathServiceOperation("getByTitle", [title], self.resource_path))
def create_field_as_xml(self, schema_xml): """ :type schema_xml: str """ field = Field(self.context) field_schema = XmlSchemaFieldCreationInformation(schema_xml) self._create_field_as_xml_query(field_schema, field) return field
def get_by_internal_name_or_title(self, name_title): """Returns the first field (2) in the collection based on the internal name or the title specified by the parameter. :param str name_title: The title or internal name to look up the field (2) by. """ return Field(self.context, ResourcePathServiceOperation("getByInternalNameOrTitle", [name_title], self.resource_path))
def get_by_id(self, _id): """ Gets the fields with the specified ID. :type _id: str """ return Field( self.context, ServiceOperationPath("getById", [_id], self.resource_path))
def add(self, field_create_information): """Adds a fields to the fields collection. :type field_create_information: office365.sharepoint.fields.field_creation_information.FieldCreationInformation """ field = Field.create_field_from_type(self.context, field_create_information) self.add_child(field) qry = CreateEntityQuery(self, field, field) self.context.add_query(qry) return field
def add_field(self, parameters): """Adds a fields to the fields collection. :type parameters: office365.sharepoint.fields.field_creation_information.FieldCreationInformation """ field = Field(self.context) self.add_child(field) qry = ServiceOperationQuery(self, "AddField", None, parameters, "parameters", field) self.context.add_query(qry) return field
def create_taxonomy_field(self, name, ssp_id, term_set_id, anchor_id="00000000-0000-0000-0000-000000000000", field_id=None, text_field_id=None, web_id=None, list_id=None): target_field = Field(self.context) field_params = { "name": name, "ssp_id": ssp_id, "term_set_id": term_set_id, "anchor_id": anchor_id, "field_id": field_id, "text_field_id": text_field_id, "list_id": list_id, "web_id": web_id, "target_field": target_field } if field_id is None: field_params["field_id"] = str(uuid.uuid1()) def _create_taxonomy_field_inner(): from office365.sharepoint.lists.list import List if isinstance(self._parent, List): parent_list = self._parent def _list_loaded(): field_params["web_id"] = parent_list.parent_web.properties["Id"] field_params["list_id"] = parent_list.properties["Id"] self._build_taxonomy_field_query(**field_params) self._parent.ensure_properties(["Id", "ParentWeb"], _list_loaded) else: def _web_loaded(): field_params["web_id"] = self.context.web.properties["Id"] self._build_taxonomy_field_query(**field_params) self.context.web.ensure_property("Id", _web_loaded) if text_field_id is None: text_field_name = f"{uuid.uuid4().hex}" text_field_schema = f''' <Field Type="Note" DisplayName="{name}_0" Hidden="TRUE" CanBeDeleted="TRUE" ShowInViewForms="FALSE" StaticName="{text_field_name}" Name="{text_field_name}"> </Field> ''' text_field = self.create_field_as_xml(text_field_schema) def _after_text_field_created(resp): field_params["text_field_id"] = text_field.properties["Id"] _create_taxonomy_field_inner() self.context.after_execute(_after_text_field_created, True) else: _create_taxonomy_field_inner() return target_field
def add(self, field_creation_information): """Adds a fields to the fields collection. :type field_creation_information: FieldCreationInformation """ field = Field.create_field_from_type( self.context, field_creation_information.FieldTypeKind) self.add_child(field) qry = CreateEntityQuery(self, field_creation_information, field) self.context.add_query(qry) return field
def create_field_as_xml(self, schema_xml, return_type=None): """ Creates a field based on the values defined in the parameters input parameter. :param str schema_xml: :type return_type: Field """ if return_type is None: return_type = Field(self.context) self.add_child(return_type) field_schema = XmlSchemaFieldCreationInformation(schema_xml) qry = ServiceOperationQuery(self, "CreateFieldAsXml", None, field_schema, "parameters", return_type) self.context.add_query(qry) return return_type
def add_dependent_lookup_field(self, displayName, primaryLookupField, lookupField): """Adds a secondary lookup field to a field (2) collection. A reference (3) to the SP.Field that was added is returned. :param str lookupField: Name of the field (2) from the target list (1) to include data from. :param Field primaryLookupField: Main lookup field to associate the dependent lookup field with. A dependent lookup field will include data from the list item referred to from the instance of the main lookup field. :param str displayName: Title of the added field """ return_field = Field(self.context) self.add_child(return_field) parameters = { "displayName": displayName, "primaryLookupField": primaryLookupField, "lookupField": lookupField } qry = ServiceOperationQuery(self, "AddDependentLookupField", None, parameters, None, return_field) self.context.add_query(qry) return return_field
def entity_type_name(self): type_name = Field.resolve_field_type(self.FieldTypeKind).__name__ return "SP.{0}".format(type_name)
def get_by_id(self, _id): """Gets the fields with the specified ID.""" return Field( self.context, ResourcePathServiceOperation("getById", [_id], self.resource_path))