The formula’s below expect a SharePoint list (called: SPList) with columns having a name related to its type:
- Choice
- Choice – Multiple values
- Date and Time – Date Only
- Lookup
- Lookup – Multiple values
- Multiple lines of text – Plain text
- Number
- Person
- Person – Multiple values
- Single line of text
- Yes/No
To make it a bit more interesting, some values depend on a control. This is explained below the low-code.
Choice
Patch(
SPList,
Defaults(SPList),
{
Title: "Patch a field of type 'Choice'",
Choice: {Value: Control_Choice.Selected.Value},
}
)
“Control_Choice” is a control of type “Drop down”
Choice – Multiple values
Option 1
Patch(
SPList,
Defaults(SPList),
{
Title: "Patch a field of type 'Choice' (Multiple selections)",
Choices: Control_Choices.SelectedItems
}
)
“Control_Choices” is a control of type “Combo box” with the property “SelectMultiple” having the value “true”.
Option 2
Patch(
SPList,
Defaults(SPList),
{
Title: "Patch a field of type 'Choice' (Multiple selections)",
Choices: coll_Choices
}
)
“coll_Choices” is a collection containing 1 column named “Value”. Example:
ClearCollect(coll_Choices, {Value:"Enter Choice #2"}, {Value:"Enter Choice #3"});
Date and Time – Date only
Patch(
SPList,
Defaults(SPList),
{
Title: "Patch a field of type 'Date and Time'",
Date: Control_DateTime.SelectedDate
}
)
“Control_DateTime” is a control of type “Date picker”. Date is a SharePoint column of type “Date and Time” configures for “Date Only”
Lookup
UpdateContext({var_Id: 2});
UpdateContext({var_Value: "22"});
Patch(
SPList,
Defaults(SPList),
{
Title: "Patch a field of type 'Lookup'",
Lookup: {Id: var_Id, Value: var_Value}
}
)
var_Id contains the list item ID of the item in the lookup list. var_Value contains the value of the configured column (Default: Title) of the item in the lookup list.
Lookup – Multiple values
Patch(
SPList,
Defaults(SPList),
{
Title: "Patch a field of type 'Lookup' - Multiple values",
Lookups: coll_Lookups
}
)
“coll_Lookups” is a collection containing 2 columns named “Id” and “Value”. Example:
ClearCollect(
coll_Lookups,
{Id: 5, Value: "Item 5"},
{Id: 8, Value: "Item 8"}
);
“Id” contains the list item ID of the item in the lookup list. “Value” contains the value of the configured column (Default: Title) of the item in the lookup list.
Multiple lines of text – Plain text
Patch(
SPList,
Defaults(SPList),
{
Title: "Patch a field of type 'Multiple lines of text'",
Multiple lines of text: Control_MLoT.Text
}
)
“Control_MLoT” is a control of type “Text input” with property “Mode” having the value “Multiline” and the property “Format” having the value “Text”.
Number
Patch(
SPList,
Defaults(SPList),
{
Title: "Patch a field of type 'Multiple lines of text'",
Number: Value(Control_Number.Text)
}
)
“Control_Number” is a control of type “Text input” with property “Mode” having the value “Single line” and the property “Format” having the value “Number”.
Person or Group
Patch(
SPList,
Defaults(SPList),
{
Title: "Patch a field of type 'Person or Group - One person'",
Person: {
Claims: "demo@formsandflows.nl",
Department: "",
DisplayName: """,
Email: "",
JobTitle: "",
Picture: ""
}
}
)
Person or Group – Multiple values
Patch(
SPList,
Defaults(SPList),
{
Title: "Patch a field of type 'Person or Group - Multiple values'",
Persons: coll_Persons
}
)
“coll_Lookups” is a collection containing the 6 columns as shown in “Person o Group”. Example:
ClearCollect(
coll_Persons,
{Claims: "demoaccount1@formsandflows.nl", Department: "", DisplayName: "", Email: "", JobTitle: "", Picture: ""},
{Claims: "demoaccount2@formsandflows.nl", Department: "", DisplayName: "", Email: "", JobTitle: "", Picture: ""}
)
Single line of text
Patch(
SPList,
Defaults(SPList),
{
Title: "Patch a field of type 'Single line of text'",
Single line of text: Control_SLoT.Text
}
)
“Control_SLoT” is a control of type “Text input” with property “Mode” having the value “Single line” and the property “Format” having the value “Text”.
Yes/No
Patch(
SPList,
Defaults(SPList),
{
Title: "Patch a field of type 'Yes/No'",
YesNo: false
}
)
This will create an item with the value “No” in the SharePoint field “YesNo”. Using “true” in the patch statement will create an item with the value “Yes”.