Set Custom Property Values
This topic provides instructions on how to set and clear one or more values for a custom string property on a component.
You will use the following operation in this topic:
| Type | Operation | Description |
|---|---|---|
| Mutation | setProperties | Sets property value(s). |
| Query | component | Retrieves an object representing a component. |
Step 1 - Set Property Values for a Component
The setProperties mutation returns SetPropertiesPayload which is used to set property value(s) to a component or its version.
- Enter the following query in the Query Pane of the Manufacturing Data Model Explorer.
Query
mutation SetStandardProperties($input: SetPropertiesInput!) { setProperties(input: $input) { targetId properties { value displayValue definition { id name specification isHidden isReadOnly isArchived description propertyBehavior units { id name } } } } }Show More - In the Query Variables Pane, enter the
targetID,propertyDefinitionIdas noted from the previous tasks, and set"value": "surface length".Note:
- The
targetIDcan be the ID of any object on which you can attach properties, such as Component and Drawing object. In this tutorial, you will be attaching a property to a component, so you will need thecomponent ID. To know how to obtain thecomponent ID, refer to Retrieve Items. - Note that different object types work with different propertyBehaviors.
- The TIMELESS property behavior works with
ComponentandDrawingobjects. - The STANDARD property behavior works with
ComponentandDrawingobjects.
- The TIMELESS property behavior works with
Query Variables
{ "input": { "targetId" : "Y29tcH5WQVZNUW1sYmxrZDBtaXJwU0NYMHJ0X0wyQ35lWmFjZUZYSUZBVzdDWDAzSkR4VkxjX2FnYX45MjU1TmphMFFlY3NUN3JhVTNrcVI3", "propertyInputs": [ { "propertyDefinitionId" : "cHJvcGRlZn5DZlhvYUM0SzUzU1R3YjZUbklyWFhaVEFJRWRkRzlBcn5DZlhvYUM0SzUzU1R3YjZUbklyWFhaVEFJRWRkRzlBcn5wcm9wX2RlZl9jb2xfMTcwNzM3NjE0MTM1N35wYXJhbWV0ZXJzLkNmWG9hQzRLNTNTVHdiNlRuSXJYWFpUQUlFZGRHOUFyOmFkNzkzNTI0ZWNkZDQ2MzE5Zjc3NzZjM2YwN2I1Y2IwLTEuMC4w", "value": "surface length" } ] } }Show More - The
- Click Play. The response will show the details of the properties that are added to the component version.
Response
{ "data": { "setProperties": { "targetId": "Y29tcH5WQVZNUW1sYmxrZDBtaXJwU0NYMHJ0X0wyQ35OWXU4a2duSVdtNGNnUVd3MmljMFl0X2FnYQ", "properties": [ { "value": "XYZ-0002", "displayValue": "XYZ-0002", "definition": { "id": "cHJvcGRlZn5DZlhvYUM0SzUzU1R3YjZUbklyWFhaVEFJRWRkRzlBcn5DZlhvYUM0SzUzU1R3YjZUbklyWFhaVEFJRWRkRzlBcn5URVNUX0NQX0RPQ35wYXJhbWV0ZXJzLkNmWG9hQzRLNTNTVHdiNlRuSXJYWFpUQUlFZGRHOUFyOmY4Mzg3MjNiOGQ1MjRjMmFhMzZkNjg3MzU5OWI0YjVhLTEuMC4w", "name": "Surface length", "specification": "FLOAT", "isHidden": false, "isReadOnly": false, "isArchived": false, "description": "description", "propertyBehavior": "STANDARD", "units": null } } ] } } }Show More
Step 2 - Validate Properties Added to the Component
You can use the component query to obtain Component object that consists property details linked to the component or component version. This task should enable you to validate the list of properties that have been added.
- Enter the following query in the Query Pane of the Manufacturing Data Model Explorer.
Query
query GetComponentProperties($componentId: ID!) { component(componentId: $componentId) { id name{ value } customProperties { results { value displayValue definition { id name specification isHidden isReadOnly isArchived description propertyBehavior units { id name } } } } } }Show More
- In the Query Variables Pane, enter the
component IDmentioned against thecomponentobject in the Retrieve Items topic.Query Variables
{ "componentId": "cHJvZHVjdH53TTBJUmZ2ZzNPVUtMdmxiMnh0Mkx0X0wyQ35aaFFydzlvREt1OGtpRUs0b1Q1UENIX2FnYQ" }
- Click Play. The response will show the details of the properties mapped to the component.
Response
{ "data": { "component": { "id": "cHJvZHVjdH53TTBJUmZ2ZzNPVUtMdmxiMnh0Mkx0X0wyQ35aaFFydzlvREt1OGtpRUs0b1Q1UENIX2FnYQ", "name": { "value": "B" }, "customProperties": { "results": [ { "value": "10D123E001", "displayValue": "10D123E001", "definition": { "id": "cHJvcGRlZn5BQ040RXZkSExNVFppdzduZmtIVXBQanNBNFZmWmFuVH5BQ040RXZkSExNVFppdzduZmtIVXBQanNBNFZmWmFuVH5wcm9wX2RlZl9jb2xfMTc0NjE4ODM3NDgzMH5wYXJhbWV0ZXJzLkFDTjRFdmRITE1UWml3N25ma0hVcFBqc0E0VmZaYW5UOjY4ZWZiNjI4MDU4YzQ4MDZhYmYzYzdlZTY1Y2E3ZWJjLTEuMC4w", "name": "ERP ID", "specification": "STRING", "isHidden": false, "isReadOnly": false, "isArchived": false, "description": "description", "propertyBehavior": "TIMELESS", "units": null } }, { "value": "Green", "displayValue": "Green", "definition": { "id": "cHJvcGRlZn5BQ040RXZkSExNVFppdzduZmtIVXBQanNBNFZmWmFuVH5BQ040RXZkSExNVFppdzduZmtIVXBQanNBNFZmWmFuVH5wcm9wX2RlZl9jb2xfMTc0NjE4ODM3NDgzMH5wYXJhbWV0ZXJzLkFDTjRFdmRITE1UWml3N25ma0hVcFBqc0E0VmZaYW5UOmM2NDRjZjBjMjJhOTQ5YzRiMTYwYzc1NGJkMmQwYWFmLTEuMC4w", "name": "Border Color 1746188552634", "specification": "STRING", "isHidden": true, "isReadOnly": false, "isArchived": false, "description": "description updated", "propertyBehavior": "STANDARD", "units": null } } ] } } } }Show More