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 query 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
,propertyDefinitionId
as noted from the previous tasks, and set"value": "surface length"
.Note:
- The
targetID
can be the ID of any object on which you can attach properties, such as Components, Component versions, Drawing, and Drawing versions. In this tutorial, you will be attaching a property to a component, so you will need therootComponent ID
of the component as a value for extendable ID from Retrieve Items. - Note that different object types work with different propertyBehaviors.
- The TIMELESS property behavior works with
Component
andDrawing
objects. - The DYNAMIC and DYNAMIC_AT_VERSION property behaviors work with ComponentVersion and DrawingVersion objects.
- The STANDARD property behavior works with tipComponentVersion and tipDrawingVersion objects.
- 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!) { mfg { component(componentId: $componentId) { id name customProperties { results { value displayValue name } } } } }
Show More - In the Query Variables Pane, enter the
componentId
mentioned against thetipRootComponentVersion
field in the Retrieve Items topic.Query Variables
{ "componentId": "Y29tcH5jby5Kd254Q0p3YVNQeWcwbGRGdUZpNkxRfktsQ0RodU00eEhMb2M5RDNNbDIxbDZfYWdh" }
- Click Play. The response will show the details of the properties mapped to the component.
Response
{ "data": { "component": { "id": "Y29tcH5WQVZNUW1sYmxrZDBtaXJwU0NYMHJ0X0wyQ35OWXU4a2duSVdtNGNnUVd3MmljMFl0X2FnYQ", "name": "Hydraulic_Bottle_Jack", "customProperties": { "results": [ { "value": "XYZ-0002", "displayValue": "XYZ-0002", "name": "ERP ID" } ] } } } }
Show More