Windchill REST Services > Windchill REST Services Domain Capabilities > Examples for Basic REST Operations > Examples for the PTC BOM Transformation Domain > Removing Department Data Associated with Plant Data
  
Removing Department Data Associated with Plant Data
You can remove single or multiple Department Data objects associated with a Plant Data object by providing the OIDs of the existing Plant Data object and the Department Data objects in the body of the request. To remove a Department Data object, you must first check out its associated Plant Data object. When you remove the Department Data object, the associated Plant Data object remains checked out. If you perform Undo Checkout on the Plant Data object, the changes are rolled back, and the association is retained. When you remove the Department Data object, the version of the Plant Data object will be iterated upon checking it in. You can specify the OID of any iteration/revision/view of the Department Data objects and Plant Data object, or their subtype in the body of the request. To remove a Department Data object, you must have Modify permissions to the Department Data object and Plant Data object, or their subtypes.
You can choose to specify an existing Change object (Change Notice or Change Task) in the request body to record the removal of the Department Data objects associated with a Plant Data object. The updated and revised Plant Data object is added as Resulting Object to the valid Change Task specified in the request body. To specify a Change object, you must have Modify permissions to the Change object or its subtype.
* 
You cannot remove a Department Data object if the specified Plant Data object is checked out by another user.
You cannot delete a Department Data object. Department Data objects are deleted automatically when they do not have an associated Plant Data object.
If you specify an invalid object in the request body, then the request fails and returns an error.
Example: Removing a Department Data Object Associated with a Plant Data Object
This example shows you how to remove a Department Data object associated with a Plant Data object. To remove the Department Data object, you must first Check Out the Plant Data object. Use the following POST URI with the request body.
URI
POST /Windchill/servlet/odata/BomTransformation/RemoveDepartmentDataAssociations
Request Headers
Content-Type: application/json
CSRF_NONCE: <Use the value from Fetch NONCE example>
Request Body
{
"PlantDataDepartmentDataAssociations": [
{
"Plant": {
"ID": "OR:com.ptc.windchill.enterprise.data.EnterpriseData:200155"
},
"DepartmentData": [
{
"ID": "OR:com.ptc.windchill.enterprise.data.PlantFunctionalData:200163"
}
]
}
]
}
Example: Removing Multiple Department Data Objects Associated with a Plant Data Object
This example shows you how to remove two Department Data objects associated with a Plant Data object. To remove the Department Data objects, you must first Check Out the Plant Data object. Use the following POST URI with the request body.
URI
POST /Windchill/servlet/odata/BomTransformation/RemoveDepartmentDataAssociations
Request Headers
Content-Type: application/json
CSRF_NONCE: <Use the value from Fetch NONCE example>
Request Body
{
"PlantDataDepartmentDataAssociations": [
{
"Plant": {
"ID": "OR:com.ptc.windchill.enterprise.data.EnterpriseData:202795"
},
"DepartmentData": [
{
"ID": "OR:com.ptc.windchill.enterprise.data.PlantFunctionalData:202816"
},
{
"ID": "OR:com.ptc.windchill.enterprise.data.PlantFunctionalData:202806"
}
]
}
]
}
Example: Removing Multiple Department Data Objects Associated with Each Plant Data Object
This example shows you how to remove multiple Department Data objects associated with each of the Plant Data objects specified in the request body. To remove the Department Data objects, you must first Check Out each associated Plant Data object. In this example, the request removes the Department Data objects associated with each of the two Plant Data objects. Use the following POST URI with the request body.
URI
POST /Windchill/servlet/odata/BomTransformation/RemoveDepartmentDataAssociations
Request Headers
Content-Type: application/json
CSRF_NONCE: <Use the value from Fetch NONCE example>
Request Body
{
"PlantDataDepartmentDataAssociations": [
{
"Plant": {
"ID": "OR:com.ptc.windchill.enterprise.data.EnterpriseData:202795"
},
"DepartmentData": [
{
"ID": "OR:com.ptc.windchill.enterprise.data.PlantFunctionalData:202903"
},
{
"ID": "OR:com.ptc.windchill.enterprise.data.PlantFunctionalData:202896"
}
]
},
{
"Plant": {
"ID": "OR:com.ptc.windchill.enterprise.data.EnterpriseData:202859"
},
"DepartmentData": [
{
"ID": "OR:com.ptc.windchill.enterprise.data.PlantFunctionalData:202880"
},
{
"ID": "OR:com.ptc.windchill.enterprise.data.PlantFunctionalData:202887"
}
]
}
]
}
Example: Removing Department Data Objects Associated with Each Plant Data Object and Recording in a Change Task
This example shows you how to remove Department Data objects associated with each Plant Data object and recording each of the updated and revised Plant Data objects in an existing Change Task specified in the request body. To remove the Department Data objects, you must first Check Out each associated Plant Data object. To specify the Change Task OID, you must have Modify permissions to it. Use the following POST URI with the request body.
URI
POST /Windchill/servlet/odata/BomTransformation/RemoveDepartmentDataAssociations
Request Headers
Content-Type: application/json
CSRF_NONCE: <Use the value from Fetch NONCE example>
Request Body
{
"ChangeOid": "VR:wt.change2.WTChangeOrder2:203216",
"PlantDataDepartmentDataAssociations": [
{
"Plant": {
"ID": "OR:com.ptc.windchill.enterprise.data.EnterpriseData:202795"
},
"DepartmentData": [
{
"ID": "OR:com.ptc.windchill.enterprise.data.PlantFunctionalData:202903"
},
{
"ID": "OR:com.ptc.windchill.enterprise.data.PlantFunctionalData:202896"
}
]
},
{
"Plant": {
"ID": "OR:com.ptc.windchill.enterprise.data.EnterpriseData:202859"
},
"DepartmentData": [
{
"ID": "OR:com.ptc.windchill.enterprise.data.PlantFunctionalData:202880"
},
{
"ID": "OR:com.ptc.windchill.enterprise.data.PlantFunctionalData:202887"
}
]
}
]
}