@@ -10,6 +10,9 @@ class Field(BaseEntity):
1010
1111    def  __init__ (self , context , resource_path = None ):
1212        super ().__init__ (context , resource_path )
13+ 
14+     @staticmethod  
15+     def  get_field_type (type_id ):
1316        from  office365 .sharepoint .fields .fieldText  import  FieldText 
1417        from  office365 .sharepoint .fields .fieldCalculated  import  FieldCalculated 
1518        from  office365 .sharepoint .fields .fieldChoice  import  FieldChoice 
@@ -21,7 +24,7 @@ def __init__(self, context, resource_path=None):
2124        from  office365 .sharepoint .fields .fieldGuid  import  FieldGuid 
2225        from  office365 .sharepoint .fields .fieldCurrency  import  FieldCurrency 
2326        from  office365 .sharepoint .fields .fieldMultiLineText  import  FieldMultiLineText 
24-         self . _field_types  =  {
27+         field_types  =  {
2528            FieldType .Text : FieldText ,
2629            FieldType .Calculated : FieldCalculated ,
2730            FieldType .Choice : FieldChoice ,
@@ -34,14 +37,25 @@ def __init__(self, context, resource_path=None):
3437            FieldType .Currency : FieldCurrency ,
3538            FieldType .Note : FieldMultiLineText 
3639        }
40+         return  field_types .get (type_id , Field )
41+ 
42+     @staticmethod  
43+     def  create_field_from_type (context , field_type ):
44+         field_type  =  Field .get_field_type (field_type )
45+         return  field_type (context )
3746
3847    def  set_show_in_display_form (self , flag ):
39-         """Sets the value of the ShowInDisplayForm property for this fields.""" 
48+         """Sets the value of the ShowInDisplayForm property for this fields. 
49+ 
50+         :type flag: bool 
51+         """ 
4052        qry  =  ServiceOperationQuery (self , "setShowInDisplayForm" , [flag ])
4153        self .context .add_query (qry )
4254
4355    def  set_show_in_edit_form (self , flag ):
44-         """Sets the value of the ShowInEditForm property for this fields.""" 
56+         """Sets the value of the ShowInEditForm property for this fields. 
57+         :type flag: bool 
58+         """ 
4559        qry  =  ServiceOperationQuery (self , "setShowInEditForm" , [flag ])
4660        self .context .add_query (qry )
4761
@@ -59,7 +73,7 @@ def delete_object(self):
5973    @property  
6074    def  internal_name (self ):
6175        """Gets a value that specifies the field internal name.""" 
62-         return  self .properties [ 'InternalName' ] 
76+         return  self .properties . get ( 'InternalName' ,  None ) 
6377
6478    def  set_property (self , name , value , persist_changes = True ):
6579        super (Field , self ).set_property (name , value , persist_changes )
@@ -68,4 +82,4 @@ def set_property(self, name, value, persist_changes=True):
6882            self ._resource_path  =  ResourcePathServiceOperation (
6983                "getById" , [value ], self ._parent_collection .resource_path )
7084        if  name  ==  "FieldTypeKind" :
71-             self .__class__  =  self ._field_types . get (value ,  Field )
85+             self .__class__  =  self .get_field_type (value )
0 commit comments