cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

Getting global attributes of WTDocument by OData

VladiSlav
17-Peridot

Getting global attributes of WTDocument by OData

Hello everyone!

 

Please tell me how can I get the values of global attributes in a WTDocument using OData?

Version of Windchill REST Services - 1.4.

Now I can only get attributes such as number and name.

 

Thanks in advance.

Regards!

 

ACCEPTED SOLUTION

Accepted Solutions
hlafkir
14-Alexandrite
(To:VladiSlav)

Hi VladiSlav,

 

Please refer to this helpful article : 

https://www.ptc.com/en/support/article/CS304928

 

 

If you have a simple IBA, you just have to add in Parts.json the following :

{

"name":"IBA",

"internalName":"IBA",

"type":"String"

}

 

  • Here an illustration with a custom enumtype (adding an IBA linked to a  Global Enumeration).

 

 

Create an entry in Parts.json, specifying a new attribute. As it is an enumeration, I will add the following :

{

                               "name": "EnumString",

"internalName": "EnumString",

"type": "PTC.EnumType"

                               }

In Parts.json, findable in codebase\rest\ptc\domain\ProdMgmt\v2\entity\Parts.json

Then it will look like this :

 

{

    "name":"Part",

    "collectionName":"Parts",

    "type":"wcType",

    "wcType":"wt.part.WTPart",

    "description":"Parts",

    "operations":"CREATE,UPDATE,DELETE",

    "attributes":[

        {   

         "name":"Name",

         "internalName":"name",

         "type":"String",

         "required":true

        }, {     

         "name":"Number",

         "internalName":"number",

         "type":"String"

        }, {     

         "name":"EndItem",

         "internalName":"endItem",

         "type":"Boolean",

         "driver":true

        }, {     

          "name":"TypeIcon",

          "internalName":"type_icon",

          "type":"PTC.Icon",

          "readOnly":true         

        }, {

          "name":"Identity",

          "internalName":"identity",

          "type":"String",

          "readOnly":true

        }, {     

          "name":"GeneralStatus",

          "internalName":"statusFamily_General",

          "type":"PTC.Icon",

          "readOnly":true         

        }, {     

          "name":"ShareStatus",

          "internalName":"statusFamily_Share",

          "type":"PTC.Icon",

          "readOnly":true         

        }, {     

          "name":"ChangeStatus",

          "internalName":"statusFamily_Change",

          "type":"PTC.Icon",

          "readOnly":true         

        }, {     

          "name":"Supersedes",

          "internalName":"statusFamily_Supersede",

          "type":"PTC.Icon",

          "readOnly":true         

        }, {

          "name":"AssemblyMode",

          "internalName":"partType",

          "type":"PTC.EnumType",

          "required":true

        }, {

          "name":"DefaultUnit",

          "internalName":"defaultUnit",

          "type":"PTC.EnumType",

          "required":true

        }, {

          "name":"DefaultTraceCode",

          "internalName":"defaultTraceCode",

          "type":"PTC.EnumType",

          "required":true

        }, {

          "name":"Source",

          "internalName":"source",

          "type":"PTC.EnumType",

          "required":true

        }, {

          "name":"ConfigurableModule",

          "internalName":"genericType",

          "type":"PTC.EnumType"

        }, {

          "name":"GatheringPart",

          "internalName":"hidePartInStructure",

          "type":"Boolean",

          "required":true

        }, {

          "name":"PhantomManufacturingPart",

          "internalName":"phantom",

          "type":"Boolean",

          "required":true

        }, {

          "name":"BOMType",

          "internalName":"variation1",

          "type":"PTC.EnumType"

        }, {

          "name":"AlternateNumber",

          "internalName":"variation2",

          "type":"PTC.EnumType"

        },{

                               "name": "EnumString",

"internalName": "EnumString",

"type": "PTC.EnumType"

                               }

    ],

    "inherits":[

        {

            "name": "versioned"

        }, {

            "name": "contextManaged"

        }, {

            "name": "lifecycleManaged"

        }, {

            "name": "viewManageable"

        }, {

            "name": "workable"

        }, {

            "name": "representable"

        }, {

            "name": "organizationOwned"

        }, {

            "name": "foldered"

        }

    ],

    "navigations":[

        {

         "name":"Uses",

         "target":"PartUses",

         "type":"PartUse",

         "isCollection":true,

         "containsTarget":true

        }, {

         "name":"UsedBy",

         "target":"Parts",

         "type":"Part",

         "isCollection":true

        }, {

         "name":"DescribedBy",

         "target":"PartDescribeLinks",

         "type":"PartDescribeLink",

         "isCollection":true,

         "containsTarget":true

        }, {

         "name":"References",

         "target":"PartReferenceLinks",

         "type":"PartReferenceLink",

         "isCollection":true,

         "containsTarget":true

        }

    ],

    "functions":[],

    "actions":[   

        {

          "name":"GetBOM",

          "description":"Get Bill Of Materials",

          "parameters": [{

              "name":"part",

              "type":"Part",

              "isNullable":false,

              "isCollection":false

          }, {

              "name":"navigationCriteriaId",

              "type":"String",

              "isNullable":true,

              "isCollection":false

          }],         

          "returnType": {

              "type":"BOM",

              "isCollection":false

          }

        }

    ]

}

Without restarting Windchill :

 

GET http://pdm10.de/Windchill/servlet/odata/ProdMgmt/Parts('VR:wt.part.WTPart:2874036') In Postman

Give this output :

{

    "@odata.context""http://pdm10.de/Windchill/servlet/odata/v2/ProdMgmt/$metadata#Parts",

    "@odata.type""#PTC.ProdMgmt.AsArticle",

    "ID""OR:wt.part.WTPart:2874037",

    "Name""MyPar",

    "Number""0000071301",

    "EndItem"false,

    "TypeIcon": {

        "Path""http://pdm10.de/Windchill/netmarkets/images/config_part.gif",

        "Tooltip""Configurable Module"

    },

    "Identity""0000071301, MyPar, Demo Organization, A (Design)",

    "GeneralStatus": {

        "Path""http://pdm10.de/Windchill/com/ptc/core/htmlcomp/images/checkedout_byyou9x9.gif",

        "Tooltip""Working copy, checked-out to you"

    },

    "ShareStatus"null,

    "ChangeStatus"null,

    "Supersedes"null,

    "AssemblyMode": {

        "Value""separable",

        "Display""Separable"

    },

    "DefaultUnit": {

        "Value""ea",

        "Display""each"

    },

    "DefaultTraceCode": {

        "Value""0",

        "Display""Untraced"

    },

    "Source": {

        "Value""make",

        "Display""Make"

    },

    "ConfigurableModule": {

        "Value""dynamic",

        "Display""Yes"

    },

    "GatheringPart"false,

    "PhantomManufacturingPart"false,

    "BOMType"null,

    "AlternateNumber"null,

    "EnumString": {

        "Value""SteelSheets",

        "Display""Steel Sheets"

    },

    "View""Design",

    "CheckoutState""Working copy, checked-out to you",

    "CheckOutStatus""cat-working-copy",

    "Comments"null,

    "State": {

        "Value""INWORK",

        "Display""In Work"

    },

 

 

if it does not work please expose here how you are driving this use case.

 

best regards

 

Hicham

 

View solution in original post

7 REPLIES 7
hlafkir
14-Alexandrite
(To:VladiSlav)

Hi VladiSlav,

 

Please refer to this helpful article : 

https://www.ptc.com/en/support/article/CS304928

 

 

If you have a simple IBA, you just have to add in Parts.json the following :

{

"name":"IBA",

"internalName":"IBA",

"type":"String"

}

 

  • Here an illustration with a custom enumtype (adding an IBA linked to a  Global Enumeration).

 

 

Create an entry in Parts.json, specifying a new attribute. As it is an enumeration, I will add the following :

{

                               "name": "EnumString",

"internalName": "EnumString",

"type": "PTC.EnumType"

                               }

In Parts.json, findable in codebase\rest\ptc\domain\ProdMgmt\v2\entity\Parts.json

Then it will look like this :

 

{

    "name":"Part",

    "collectionName":"Parts",

    "type":"wcType",

    "wcType":"wt.part.WTPart",

    "description":"Parts",

    "operations":"CREATE,UPDATE,DELETE",

    "attributes":[

        {   

         "name":"Name",

         "internalName":"name",

         "type":"String",

         "required":true

        }, {     

         "name":"Number",

         "internalName":"number",

         "type":"String"

        }, {     

         "name":"EndItem",

         "internalName":"endItem",

         "type":"Boolean",

         "driver":true

        }, {     

          "name":"TypeIcon",

          "internalName":"type_icon",

          "type":"PTC.Icon",

          "readOnly":true         

        }, {

          "name":"Identity",

          "internalName":"identity",

          "type":"String",

          "readOnly":true

        }, {     

          "name":"GeneralStatus",

          "internalName":"statusFamily_General",

          "type":"PTC.Icon",

          "readOnly":true         

        }, {     

          "name":"ShareStatus",

          "internalName":"statusFamily_Share",

          "type":"PTC.Icon",

          "readOnly":true         

        }, {     

          "name":"ChangeStatus",

          "internalName":"statusFamily_Change",

          "type":"PTC.Icon",

          "readOnly":true         

        }, {     

          "name":"Supersedes",

          "internalName":"statusFamily_Supersede",

          "type":"PTC.Icon",

          "readOnly":true         

        }, {

          "name":"AssemblyMode",

          "internalName":"partType",

          "type":"PTC.EnumType",

          "required":true

        }, {

          "name":"DefaultUnit",

          "internalName":"defaultUnit",

          "type":"PTC.EnumType",

          "required":true

        }, {

          "name":"DefaultTraceCode",

          "internalName":"defaultTraceCode",

          "type":"PTC.EnumType",

          "required":true

        }, {

          "name":"Source",

          "internalName":"source",

          "type":"PTC.EnumType",

          "required":true

        }, {

          "name":"ConfigurableModule",

          "internalName":"genericType",

          "type":"PTC.EnumType"

        }, {

          "name":"GatheringPart",

          "internalName":"hidePartInStructure",

          "type":"Boolean",

          "required":true

        }, {

          "name":"PhantomManufacturingPart",

          "internalName":"phantom",

          "type":"Boolean",

          "required":true

        }, {

          "name":"BOMType",

          "internalName":"variation1",

          "type":"PTC.EnumType"

        }, {

          "name":"AlternateNumber",

          "internalName":"variation2",

          "type":"PTC.EnumType"

        },{

                               "name": "EnumString",

"internalName": "EnumString",

"type": "PTC.EnumType"

                               }

    ],

    "inherits":[

        {

            "name": "versioned"

        }, {

            "name": "contextManaged"

        }, {

            "name": "lifecycleManaged"

        }, {

            "name": "viewManageable"

        }, {

            "name": "workable"

        }, {

            "name": "representable"

        }, {

            "name": "organizationOwned"

        }, {

            "name": "foldered"

        }

    ],

    "navigations":[

        {

         "name":"Uses",

         "target":"PartUses",

         "type":"PartUse",

         "isCollection":true,

         "containsTarget":true

        }, {

         "name":"UsedBy",

         "target":"Parts",

         "type":"Part",

         "isCollection":true

        }, {

         "name":"DescribedBy",

         "target":"PartDescribeLinks",

         "type":"PartDescribeLink",

         "isCollection":true,

         "containsTarget":true

        }, {

         "name":"References",

         "target":"PartReferenceLinks",

         "type":"PartReferenceLink",

         "isCollection":true,

         "containsTarget":true

        }

    ],

    "functions":[],

    "actions":[   

        {

          "name":"GetBOM",

          "description":"Get Bill Of Materials",

          "parameters": [{

              "name":"part",

              "type":"Part",

              "isNullable":false,

              "isCollection":false

          }, {

              "name":"navigationCriteriaId",

              "type":"String",

              "isNullable":true,

              "isCollection":false

          }],         

          "returnType": {

              "type":"BOM",

              "isCollection":false

          }

        }

    ]

}

Without restarting Windchill :

 

GET http://pdm10.de/Windchill/servlet/odata/ProdMgmt/Parts('VR:wt.part.WTPart:2874036') In Postman

Give this output :

{

    "@odata.context""http://pdm10.de/Windchill/servlet/odata/v2/ProdMgmt/$metadata#Parts",

    "@odata.type""#PTC.ProdMgmt.AsArticle",

    "ID""OR:wt.part.WTPart:2874037",

    "Name""MyPar",

    "Number""0000071301",

    "EndItem"false,

    "TypeIcon": {

        "Path""http://pdm10.de/Windchill/netmarkets/images/config_part.gif",

        "Tooltip""Configurable Module"

    },

    "Identity""0000071301, MyPar, Demo Organization, A (Design)",

    "GeneralStatus": {

        "Path""http://pdm10.de/Windchill/com/ptc/core/htmlcomp/images/checkedout_byyou9x9.gif",

        "Tooltip""Working copy, checked-out to you"

    },

    "ShareStatus"null,

    "ChangeStatus"null,

    "Supersedes"null,

    "AssemblyMode": {

        "Value""separable",

        "Display""Separable"

    },

    "DefaultUnit": {

        "Value""ea",

        "Display""each"

    },

    "DefaultTraceCode": {

        "Value""0",

        "Display""Untraced"

    },

    "Source": {

        "Value""make",

        "Display""Make"

    },

    "ConfigurableModule": {

        "Value""dynamic",

        "Display""Yes"

    },

    "GatheringPart"false,

    "PhantomManufacturingPart"false,

    "BOMType"null,

    "AlternateNumber"null,

    "EnumString": {

        "Value""SteelSheets",

        "Display""Steel Sheets"

    },

    "View""Design",

    "CheckoutState""Working copy, checked-out to you",

    "CheckOutStatus""cat-working-copy",

    "Comments"null,

    "State": {

        "Value""INWORK",

        "Display""In Work"

    },

 

 

if it does not work please expose here how you are driving this use case.

 

best regards

 

Hicham

 

VladiSlav
17-Peridot
(To:hlafkir)

Thank you very much for your reply!

I added these lines to Documents.json:

{
 "name":"IBA",
 "internalName":"IBA",
 "type":"String"
}, {
 "name": "EnumString",
 "internalName": "EnumString",
 "type": "PTC.EnumType"
}        

And I get these answers to the request:

<d:EnumString m:null="true"/>
<d:IBA m:null="true"/>

here is the main part of my request:

Windchill/servlet/odata/v1/DocMgmt/Documents

What am I doing wrong?

Thanks in advance!

hlafkir
14-Alexandrite
(To:VladiSlav)

Hi, 

 

But what are the internal names of your global attributes ? (in type and attribute manager) 

 

Hicham

VladiSlav
17-Peridot
(To:hlafkir)

oh sure!
Now everything worked, thanks a lot!

VladiSlav
17-Peridot
(To:hlafkir)

One more question if you can)

I used to think that enumerations have only one name and several values.
But in your example it looks like a key - value.

"EnumString": {
"Value": "SteelSheets",
"Display": "Steel Sheets"
}

Do I understand correctly?
How can I do it?

Thanks in advance!

hlafkir
14-Alexandrite
(To:VladiSlav)

 

HI, follow these screenshots :

create an IBA and add constraint enumerationcreate an IBA and add constraint enumerationthe global enumeratoin to be added into the IBAthe global enumeratoin to be added into the IBAafter creating a part and added a value to the attributeafter creating a part and added a value to the attributePostman responsePostman response

Hope this is now clear 🙂

 

Best reagrds,

Hicham

VladiSlav
17-Peridot
(To:hlafkir)

Thank you so much!

Announcements

Top Tags