-
-
Notifications
You must be signed in to change notification settings - Fork 318
/
form_update_value.py
51 lines (44 loc) · 1.78 KB
/
form_update_value.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from datetime import datetime
from office365.runtime.client_value import ClientValue
from office365.sharepoint.fields.lookup_value import FieldLookupValue
class ListItemFormUpdateValue(ClientValue):
"""Specifies the properties of a list item field and its value."""
def __init__(
self,
name=None,
value=None,
has_exception=None,
error_code=None,
error_message=None,
):
"""
:param str name: Specifies the field internal name for a field.
:param str value: Specifies a value for a field.
:param bool has_exception: Specifies whether there was an error result after validating the value for the field
param int ErrorCode: Specifies the error code after validating the value for the field
"""
super(ListItemFormUpdateValue, self).__init__()
self.FieldName = name
self.FieldValue = value
self.HasException = has_exception
self.ErrorCode = error_code
self.ErrorMessage = error_message
def __repr__(self):
if self.HasException:
return "{0} update failed: Message: {1}".format(
self.FieldName, self.ErrorMessage
)
else:
return "{0} update succeeded".format(self.FieldName)
def to_json(self, json_format=None):
json = super(ListItemFormUpdateValue, self).to_json(json_format)
if isinstance(self.FieldValue, FieldLookupValue):
json["FieldValue"] = (
"[{" + "'Key':'{0}'".format(self.FieldValue.LookupValue) + "}]"
)
elif isinstance(self.FieldValue, datetime):
json["FieldValue"] = self.FieldValue.isoformat()
return json
@property
def entity_type_name(self):
return "SP.ListItemFormUpdateValue"