Windchill REST Services > Windchill REST Services Domain Capabilities > Examples for Basic REST Operations > Examples for the PTC Manufacturing Process Management Domain > Updating Attributes of Operation
  
Updating Attributes of Operation
To update the attributes of an existing Operation object or its subtype, you must first check out the object. Similarly, you can also update the attributes of an existing Standard Operation object or its subtype.
If you perform Undo Checkout on the Operation object, the changes are rolled back. When you update the Operation object, the version of the Operation object will be iterated upon checking it in. You can specify the OID of any iteration/revision/view of the Operation object or its subtype. You can update modeled and all other types of attributes, including IBAs such as enumerated lists.
To update an attribute, you must specify the value with its valid internal name. If a constraint is applied to the attribute, you must specify the internal name of the value specified in the constraint.
If you want to clear the value of an attribute, you can specify its value as null in the request.
If you do not specify an attribute in the request body, then the attribute retains its existing value.
* 
You cannot modify the following attributes: Name, Number, Category, Unit.
Example: Updating Attributes of an Operation
This example shows you how to update the attributes of an Operation object. Use the following PATCH URI with the request body.
URI
PATCH /Windchill/servlet/odata/MfgProcMgmt/Operations('OR:com.ptc.windchill.mpml.processplan.operation.MPMOperation:200152')
Request Headers
Content-Type: application/json
CSRF_NONCE: <Use the value from Fetch NONCE example>
Request Body
{
"MoveTime": {
"Precision": 0,
"Value": 0
},
"QueueCost": {
"Precision": 0,
"Value": 0
},
"OutSourced": true,
"ProcessingTime": {
"Precision": 0,
"Value": 0
},
"SetupTime": {
"Precision": 0,
"Value": 0
},
"TeardownCost": {
"Precision": 0,
"Value": 0
},
"WaitingCost": {
"Precision": 0,
"Value": 0
},
"SubOperationInWorkInstruction": true,
"OtherCost": {
"Precision": 0,
"Value": 0
},
"LaborTime": {
"Precision": 0,
"Value": 0
},
"WaitingTime": {
"Precision": 0,
"Value": 0
},
"ERPValidationCode": "K1",
"InspectionInterval": "Daily",
"QueueTime": {
"Precision": 0,
"Value": 0
},
"LaborCost": {
"Precision": 0,
"Value": 0
},
"ERPSubOperationPublished": true,
"Scheduled": true,
"InspectionNeeded": true,
"SetupCost": {
"Precision": 0,
"Value": 0
},
"MoveCost": {
"Precision": 0,
"Value": 0
},
"TeardownTime": {
"Precision": 0,
"Value": 0
},
"ProcessingCost": {
"Precision": 0,
"Value": 0
},
"OutSourced": true,
"Description": "Operation1",
"Quantity": 2,
"OtherTime": {
"Precision": 0,
"Value": 0
},
"LagTime": {
"Precision": 0,
"Value": 0
},
"SubOperationTimeIncluded": true,
"CustomAttribute": "Test"
}
* 
Similarly, you can update the attributes of a Standard Operation object by specifying its OID in the request URI.
Example: Updating Attributes of Multiple Operations
This example shows you how to update the attributes of two Operation objects specified in the request body. Use the following POST URI with the request body.
URI
POST /Windchill/servlet/odata/MfgProcMgmt/UpdateOperations
Request Headers
Content-Type: application/json
CSRF_NONCE: <Use the value from Fetch NONCE example>
Request Body
{
"Operations": [
{
"State": {
"Display": "In Work",
"Value": "In Work"
},
"Latest": true,
"MoveCost": {
"Precision": 0,
"Value": 0
},
"QueueTime": {
"Precision": 0,
"Value": 1
},
"WaitingTime": {
"Precision": 0,
"Value": 1
},
"OutSourced": true,
"ProcessingCost": {
"Precision": 0,
"Value": 1
},
"SetupCost": {
"Precision": 0,
"Value": 1
},
"SetupTime": {
"Precision": 0,
"Value": 1
},
"ID": "OR:com.ptc.windchill.mpml.processplan.operation.MPMStandardOperation:228201",
"WorkInProgressState": {
"Display": "WIP",
"Value": "WIP"
},
"OtherCost": {
"Precision": 0,
"Value": 1
},
"SubOperationInWorkInstruction": true,
"TeardownTime": {
"Precision": 0,
"Value": 1
},
"LaborTime": {
"Precision": 0,
"Value": 1
},
"WaitingCost": {
"Precision": 0,
"Value": 1
},
"ERPValidationCode": "K1",
"ProcessingTime": {
"Precision": 0,
"Value": 1
},
"MoveTime": {
"Precision": 0,
"Value": 1
},
"ERPSubOperationPublished": true,
"QueueCost": {
"Precision": 0,
"Value": 1
},
"Scheduled": true,
"TeardownCost": {
"Precision": 0,
"Value": 1
},
"InspectionNeeded": true,
"LagTime": {
"Precision": 0,
"Value": 1
},
"OtherTime": {
"Precision": 0,
"Value": 1
},
"Quantity": 0,
"LaborCost": {
"Precision": 0,
"Value": 1
},
"SubOperationTimeIncluded": true
},
{
"State": {
"Display": "In Work",
"Value": "In Work"
},
"Latest": true,
"MoveCost": {
"Precision": 0,
"Value": 1
},
"QueueTime": {
"Precision": 0,
"Value": 1
},
"WaitingTime": {
"Precision": 0,
"Value": 1
},
"OutSourced": true,
"ProcessingCost": {
"Precision": 0,
"Value": 1
},
"SetupCost": {
"Precision": 0,
"Value": 1
},
"SetupTime": {
"Precision": 0,
"Value": 1
},
"ID": "OR:com.ptc.windchill.mpml.processplan.operation.MPMStandardOperation:228208",
"WorkInProgressState": {
"Display": "WIP",
"Value": "WIP"
},
"OtherCost": {
"Precision": 0,
"Value": 1
},
"SubOperationInWorkInstruction": true,
"TeardownTime": {
"Precision": 0,
"Value": 1
},
"LaborTime": {
"Precision": 0,
"Value": 1
},
"WaitingCost": {
"Precision": 0,
"Value": 1
},
"ERPValidationCode": "K1",
"ProcessingTime": {
"Precision": 0,
"Value": 1
},
"MoveTime": {
"Precision": 0,
"Value": 1
},
"ERPSubOperationPublished": true,
"QueueCost": {
"Precision": 0,
"Value": 1
},
"Scheduled": true,
"TeardownCost": {
"Precision": 0,
"Value": 1
},
"InspectionNeeded": true,
"LagTime": {
"Precision": 0,
"Value": 1
},
"OtherTime": {
"Precision": 0,
"Value": 1
},
"Quantity": 0,
"LaborCost": {
"Precision": 0,
"Value": 1
},
"SubOperationTimeIncluded": true,
"CustomAttribute": "Test2"
}
]
}
* 
Similarly, you can update the attributes of multiple Standard Operation objects by specifying their OIDs in the request body. You can update the attributes of Standard Operation and Operation objects simultaneously, by specifying their respective OIDs in the same request body.
Updating Operations in Context of Change
This example shows you how to update two Operations in the context of Change. In this example, one change task object is specified for each Operation object in the request body. Use the following POST URI with the request body.
URI
POST /Windchill/servlet/odata/MfgProcMgmt/UpdateOperations
Request Headers
Content-Type: application/json
CSRF_NONCE: <Use the value from Fetch NONCE example>
Request Body
{
"Operations": [
{
"ID": "OR:com.ptc.windchill.mpml.processplan.operation.MPMOperation:200501",
"Description": "Description1",
"ResultedByObjects@odata.bind": [
"ChangeTasks('VR:wt.change2.WTChangeActivity2:205227')"
]
},
{
"ID": "OR:com.ptc.windchill.mpml.processplan.operation.MPMOperation:200105",
"Description": "Description2",
"ResultedByObjects@odata.bind": [
"ChangeTasks('VR:wt.change2.WTChangeActivity2:205227')"
]
}
]
}
The request updates and adds the modified Operation object as a Resultant object to the specified Change object.