Remove Custom Property Value
This topic provides instructions on how to clear value for a custom string property on a component.
You will use the following operations in this topic:
| Type | Operation | Description |
|---|---|---|
| Mutation | setProperties | Sets or Clears property value(s). |
| Query | component | Retrieves an object representing a component. |
Step 1 - Clear Property values for a Component
The setProperties mutation returns SetPropertiesPayload which is used to remove property value(s) from a component or its version.
- Enter the following query in the Query Pane of the Manufacturing Data Model Explorer.
Query
mutation ClearProperties($input: SetPropertiesInput!) { setProperties(input: $input) { targetId properties { value } } }Show More - In the Query Variables Pane, enter the
targetId,propertyDefinitionIdand also set the"shouldClear"condition to"true".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" : "cHJvZHVjdH53TTBJUmZ2ZzNPVUtMdmxiMnh0Mkx0X0wyQ35aaFFydzlvREt1OGtpRUs0b1Q1UENIX2FnYQ", "propertyInputs": [ { "propertyDefinitionId" : "cHJvcGRlZn5BQ040RXZkSExNVFppdzduZmtIVXBQanNBNFZmWmFuVH5BQ040RXZkSExNVFppdzduZmtIVXBQanNBNFZmWmFuVH5wcm9wX2RlZl9jb2xfMTc0NjE4ODM3NDgzMH5wYXJhbWV0ZXJzLkFDTjRFdmRITE1UWml3N25ma0hVcFBqc0E0VmZaYW5UOmM2NDRjZjBjMjJhOTQ5YzRiMTYwYzc1NGJkMmQwYWFmLTEuMC4w" } ] } }Show More - The
- Click Play. The response will remove the details of the properties that are deleted from the component version.
Response
{ "data": { "setProperties": { "targetId": "cHJvZHVjdH53TTBJUmZ2ZzNPVUtMdmxiMnh0Mkx0X0wyQ35aaFFydzlvREt1OGtpRUs0b1Q1UENIX2FnYQ", "properties": [ { "value": null } ] } } }Show More
Step 2 - Validate if the Custom Property Value is Removed
You can use the component query to obtain a Component object that includes property details linked to the component or component version. This step will help you 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 customProperties { results { value displayValue name } } } }Show More - In the Query Variables Pane, enter the
componentIdmentioned against thetipRootComponentVersionfield in Retrieve Items topic.Query Variables
{ "componentId": "Y29tcH5WQVZNUW1sYmxrZDBtaXJwU0NYMHJ0X0wyQ35OWXU4a2duSVdtNGNnUVd3MmljMFl0X2FnYQ" }
- Click Play. The response will show the details of the properties removed to the component.
Response
{ "data": { "component": { "id": "Y29tcH5WQVZNUW1sYmxrZDBtaXJwU0NYMHJ0X0wyQ35OWXU4a2duSVdtNGNnUVd3MmljMFl0X2FnYQ", "name": "Hydraulic_Bottle_Jack", "customProperties": { "results": [] } } } }Show More