Set Property(Preview)
Template ID: setproperty
Adds or updates a property in a collection or an object. Value can be a constant, value of another property or a combination of both. This template is available in Power Apps and Power Automate.
In this article
To start, specify the path to the parent and the property to add or update as a subpath within the parent. Next, specify a value that the property will be updated with. This value can be either a constant, a path to a property, or a combination of both.
Examples
Let’s look at some examples that use the following parameters.
Example 1
Input JSON:
{
"peopleObject":{
"XYZ":{
"Age": "30"
},
"ABC":{
"Age": "23"
}
}
}
Input Parameter | Value |
newPropertyParentPathTemplate | @body().peopleObject |
newPropertySubPathTemplateh | location |
propertyValuePathTemplate | USA |
Output JSON:
{
"peopleObject":{
"location": "USA",
"XYZ":{
"Age": "3;0"
},
"ABC":{
"Age": "23"
}
}
}
Example 2
Input JSON:
{
"people":[
{
"name":"xyz"
},
{
"name":"pqr"
}
]
}
Input Parameter | Value |
newPropertyParentPathTemplate | @body().people |
newPropertySubPathTemplateh | age |
propertyValuePathTemplate | 30 |
Output JSON:
{
"people":[
{
"name":"xyz",
"age": "30"
},
{
"name":"pqr",
"age": "30"
}
]
}
Example 3
Input JSON:
{
"firstName": "John",
"lastName": "Smith"
}
Input Parameter | Value |
newPropertyParentPathTemplate | @body() |
newPropertySubPathTemplateh | name |
propertyValuePathTemplate | {@body().firstName} {@body().lastName} |
Output JSON:
{
"firstName": "John",
"lastName": "Smith",
"name": "John Smith"
}
Examples from open-sourced connectors
We have a few instances of this template being used in our open-sourced connectors repository.
Connector | Scenario | |
Planner | Sets a new property called previewProperty with a value of ! | |
AzureAD | Sets a new property that takes the value from a URL |
Input Parameters
Name | Key | Required | Type | Description |
---|---|---|---|---|
Parent object or collection path |
x-ms-apimTemplateParameter.newPropertyParentPathTemplate | True | String | Path to the parent object or collection to which property will be added. |
Path relative to parent |
x-ms-apimTemplateParameter.newPropertySubPathTemplate | True | String | Property subpath within the parent object or collection. |
Value to add |
x-ms-apimTemplateParameter.propertyValuePathTemplate | True | String | A constant, path to the property or a combination of both. |
Run policy on |
x-ms-apimTemplate-policySection | True | Enum | Specifies when to run this policy - Request : Policy template will run before request is sent to the backend API. - Response : Policy will run after receiving response from the backend API. |
Operations |
x-ms-apimTemplate-operationName | Array | List of actions and triggers to which the policy will apply to. If no operation is selected, this policy will apply to all operations. |