5
5
from office365 .runtime .resource_path_service_operation import ResourcePathServiceOperation
6
6
from office365 .sharepoint .base_entity_collection import BaseEntityCollection
7
7
from office365 .sharepoint .fields .field import Field
8
+ from office365 .sharepoint .fields .field_creation_information import FieldCreationInformation
9
+ from office365 .sharepoint .fields .field_type import FieldType
8
10
from office365 .sharepoint .fields .xmlSchemaFieldCreationInformation import XmlSchemaFieldCreationInformation
9
11
10
12
@@ -18,6 +20,59 @@ def create_typed_object(self, properties):
18
20
field = super (FieldCollection , self ).create_typed_object (properties )
19
21
return field
20
22
23
+ def add_url_field (self , title , description = None ):
24
+ """
25
+ Adds Url field
26
+
27
+ :param str title:
28
+ :param str or None description:
29
+ :return:
30
+ """
31
+ create_field_info = FieldCreationInformation (title = title ,
32
+ description = description ,
33
+ field_type_kind = FieldType .URL )
34
+ return self .add (create_field_info )
35
+
36
+ def add_lookup_field (self , title , lookup_list_id , lookup_field_name , allow_multiple_values = False ):
37
+ """
38
+ Adds Lookup field
39
+
40
+ :param bool allow_multiple_values:
41
+ :param str lookup_field_name:
42
+ :param str lookup_list_id:
43
+ :param str title:
44
+ """
45
+ if allow_multiple_values :
46
+ field_schema = f'''
47
+ <Field Type="LookupMulti" Mult="TRUE" DisplayName="{ title } " Required="FALSE" Hidden="TRUE" \
48
+ ShowField="{ lookup_field_name } " List="{{{ lookup_list_id } }}" StaticName="{ title } " Name="{ title } ">
49
+ </Field>
50
+ '''
51
+ target_field = self .create_field_as_xml (field_schema )
52
+ else :
53
+ create_field_info = FieldCreationInformation (title = title ,
54
+ lookup_list_id = lookup_list_id ,
55
+ lookup_field_name = lookup_field_name ,
56
+ field_type_kind = FieldType .Lookup )
57
+ target_field = self .add_field (create_field_info )
58
+ return target_field
59
+
60
+ def add_choice_field (self , title , values , multiple_values = False ):
61
+ """
62
+ Adds Choice field
63
+
64
+ :param bool multiple_values:
65
+ :param list[str] values:
66
+ :param str title:
67
+ """
68
+ fld_type = FieldType .MultiChoice if multiple_values else FieldType .Choice
69
+ create_field_info = FieldCreationInformation (title , fld_type )
70
+ [create_field_info .Choices .add (choice ) for choice in values ]
71
+ return self .add_field (create_field_info )
72
+
73
+ def add_user_field (self ):
74
+ pass
75
+
21
76
def add (self , field_create_information ):
22
77
"""Adds a fields to the fields collection.
23
78
0 commit comments