Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SharePoint REST API Add/ValidateUpdateListItems
See:
- https://robertschouten.com/2018/04/30/update-file-metadata-with-rest-api-using-validateupdatelistitem-method/
- http://blog.arvosys.com/2018/07/06/list-items-system-update-options-in-sharepoint-online/index.html
FieldValues =
[
// Text field (single line and note)
{ FieldName: "TextField", FieldValue: "123" },
// Number field
{ FieldName: "NumberField", FieldValue: "123" },
// Yes/No field
{ FieldName: "YesNoField", FieldValue: "1" /* 0 = (No/False) or 1 = (Yes/True) */ },
// Person or group, single-value (SPO)
{ FieldName: "PersonField", FieldValue: JSON.stringify([{ Key: "i:0#.f|membership|eve@contoso.com" }]) },
// Person or group, multi-value (SPO)
{ FieldName: "PersonField", FieldValue: JSON.stringify([{ Key: "i:0#.f|membership|eve@contoso.com" }, { Key: "i:0#.f|membership|alice@contoso.com" }]) },
// Person or group, single-value (SPServer)
{ FieldName: "PersonField", FieldValue: JSON.stringify([{ Key: "i:0#.w|eve@contoso.com" }]) },
// Person or group, multi-value (SPServer)
{ FieldName: "PersonField", FieldValue: JSON.stringify([{ Key: "i:0#.w|eve@contoso.com" }, { Key: "i:0#.w|alice@contoso.com" }]) },
// Date field
{ FieldName: "DateTimeField", FieldValue: "6/23/2018 10:15 PM" },
{ FieldName: "DateField", FieldValue: "6/23/2018" },
// Choice field (single and multi-valued)
{ FieldName: "ChoiceField", FieldValue: "Choice 1" },
{ FieldName: "MultiChoiceField", FieldValue: "Choice 1;#Choice 2" },
// Hyperlink or picture (optional description goes after the URL separated by a comma e.g. ", ")
{ FieldName: "HyperlinkField", FieldValue: "https://arvosys.com, ARVO Systems" },
// Lookups fields (single and multi-value)
{ FieldName: "LookupField", FieldValue: "2" /* Item ID as string */ },
{ FieldName: "MutliLookupField", FieldValue: "1;#2;#3;#4;#5" },
// Managed metadata (Taxonomy) fields single-value
{ FieldName: "SingleMMDField", FieldValue: "Department 2|-1|220a3627-4cd3-453d-ac54-34e71483bb8a;" },
// Managed metadata (Taxonomy) fields multi-value
{ FieldName: "MultiMMDField", FieldValue: "Department 2|-1|220a3627-4cd3-453d-ac54-34e71483bb8a;Department 3|-1|700a1bc3-3ef6-41ba-8a10-d3054f58db4b;" }
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment