Request

Response

    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:

    TypeOperationDescription
    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.

    1. 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
    2. 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 the rootComponent 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 and Drawing 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.

      Query Variables

      {
      "input": {
          "targetId" : "Y29tcH5WQVZNUW1sYmxrZDBtaXJwU0NYMHJ0X0wyQ35lWmFjZUZYSUZBVzdDWDAzSkR4VkxjX2FnYX45MjU1TmphMFFlY3NUN3JhVTNrcVI3",
          "propertyInputs": [
              {
                  "propertyDefinitionId" : "cHJvcGRlZn5DZlhvYUM0SzUzU1R3YjZUbklyWFhaVEFJRWRkRzlBcn5DZlhvYUM0SzUzU1R3YjZUbklyWFhaVEFJRWRkRzlBcn5wcm9wX2RlZl9jb2xfMTcwNzM3NjE0MTM1N35wYXJhbWV0ZXJzLkNmWG9hQzRLNTNTVHdiNlRuSXJYWFpUQUlFZGRHOUFyOmFkNzkzNTI0ZWNkZDQ2MzE5Zjc3NzZjM2YwN2I1Y2IwLTEuMC4w",
                  "value": "surface length"
              }
            ]
          }
        }
      
      Show More

    1. 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.

    1. 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
    2. In the Query Variables Pane, enter the componentId mentioned against the tipRootComponentVersion field in the Retrieve Items topic.

      Query Variables

      {
        "componentId": "Y29tcH5jby5Kd254Q0p3YVNQeWcwbGRGdUZpNkxRfktsQ0RodU00eEhMb2M5RDNNbDIxbDZfYWdh"
      }
      

    1. 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