Patch

Records (Lists) and files (Document libraries) have properties (columns) and each property has a type. The function “Patch” can be used to change (Add, Edit, Remove) property values. The syntax how to change property value depends on its type.

This content page shows the syntax of most used property types.

I strongly recommend not using the property type “Lookup” and “Managed Metadata”. They increase the change on data loss (Lookup) and increase complexity.

I also do not recommend using the property type “Choice”.

My preferred way for drop-downs in a canvas app is by using a dedicated list for all choices. This way:

  • You can delegate the management to a functional application manager without having to give elevated privileges on lists/document libraries.
  • You can add extra properties to a choice allowing
    • to disable/enable choices easy.
    • the creation of cascading drop downs easy.

The data is stored in a “Single line of text” column for single-select choices and a “Multiple lines of text” column for multi-select choices.


Choice (Single value)

Choice: {Value: "Enter Choice #2"}

Choice (Multiple values)

Choices: [{Value: "Enter Choice #1"}, {Value: "Enter Choice #2"}]

Currency

Currency: 1.23

Date and Time (Date only)

Date: Date(2023, 10, 9)

Date and Time (Date & Time)

'Date and Time': Date(2023,10,9) + Time(23, 10, 9)

Hyperlink or Picture

'Hyperlink or Picture': "https://www.formsandflows.nl"

It is not possible to add a description to a hyperlink field using the function “Patch”.

Multiple lines of text

'Multiple lines of text': "Example"

Number

Number: 1.2345

Person or Group (Single value)

Person: {
    Claims: "example@formsandflows.nl",
    Department: "", DisplayName: "", Email: "", JobTitle: "", Picture: ""
}

Person or Group (Multiple values)

Persons: [{
    Claims: "example1@formsandflows.nl",
    Department: "", DisplayName: "", Email: "", JobTitle: "", Picture: ""
}, {
    Claims: "example2@formsandflows.nl",
    Department: "", DisplayName: "", Email: "", JobTitle: "", Picture: ""
}]

Single line of text

'Single line of text': "Example"

Yes/No

YesNo: true

Full example

Patch(<List>, Defaults(<List>), {
    Title: GUID(),
    Choice: {Value: "Enter Choice #2"},
    Choices: [{Value: "Enter Choice #1"}, {Value: "Enter Choice #2"}],
    Currency: 1.23,
    Date: Date(2023, 10, 9),
    'Date and Time': Date(2023, 10, 9) + Time(23, 10, 9),
    'Hyperlink or Picture': "https://www.formsandflows.nl",
    'Multiple lines of text': "Example",
    Number: 1.2345,
    Person: {
        Claims: "rick@formsandflows.nl",
        Department: "", DisplayName: "", Email: "", JobTitle: "", Picture: "" },
    Persons: [{
        Claims: "rick@formsandflows.nl", Department: "", DisplayName: "", Email: "", JobTitle: "", Picture: ""
    }, {
        Claims: "adminone@formsandflows.nl",
        Department: "", DisplayName: "", Email: "", JobTitle: "", Picture: ""
    }],
    'Single line of text': "Example",
    YesNo: true
})

, where <List> is the name of a SharePoint list.

You cannot add a file to a document library with the patch function. A cloud flow must be used for that. After the file is added, its properties can be changed.

Links

Feedback

Please enable JavaScript in your browser to complete this form.

You can use the form below to submit feedback if you think that content on this page:

  • is wrong. Please then also provide what is wrong and why.
  • could be more comprehensive. Please then also provide which content should be added/updated.

Thank you!