Windchill REST Services > Windchill REST Services Domain Capabilities > Examples for Basic REST Operations > Examples for the PTC Enterprise Systems Integration Domain > Updating Subtransactions and the Transaction
  
Updating Subtransactions and the Transaction
You can update the status of an enterprise systems transaction using the PostResultForTransaction action. You can also update the status of one or more subtransactions in a transaction using the PostResultForSubTransaction action.
You can update the status of one or more subtransactions in a transaction and accordingly the status of the transaction using the PostResultForTransactionAndSubtransaction action.
* 
Using these APIs, you can update the actual status of the object imports, or data that is exchanged, in an ERP/MES system in Windchill.
The data delivered by the ESI/ERPConnector solution to the target system is automatically acknowledged because, by default the ESI > Settings > Transaction > Enable Post Result preference is set to Yes in Windchill.
When the ESI > Settings > Transaction > Enable Post Result preference is set to No, the ESI transaction status is displayed as Pending until the Release To Manufacturing workflow receives a confirmation of the publication status from the external system. Using these APIs, you can update the status based on how the data is imported or consumed in an ERP/MES system, and the ESI transaction is updated accordingly.
In the case of a failure, the Release To Manufacturing workflow enables you to resolve the errors or data anomalies, and to resume the export until the source and target systems are synchronized.
Using the PostResultForTransactionAndSubtransaction action, you can update the publication status of one or more subtransactions and accordingly the transaction for the specified primary Windchill business object, in a single call.
* 
In Windchill, a transaction is successfully published with its status as Succeeded when the status of each subtransaction passed in the PostResultForTransactionAndSubtransaction action is updated as Succeeded.
When the status of each subtransaction is passed as true in the PostResultForTransactionAndSubtransaction action, the request updates the status of the transaction as Succeeded and the transaction is successfully published. If the status of any one subtransaction is passed as false, the request updates the status of the transaction as Failed.
The attributes in the request payload of the PostResultForTransactionAndSubtransaction action are described in the following table:
Attribute
Description
TransactionID
Required. The transaction ID for this action.
Message
Optional. The message that indicates the reason for the Succeeded or Failed status for the specified transaction ID.
PrimaryBuisnessObjectID
Required. The primary business object ID for this action. This attribute is required for updating the status of the specified transaction.
ReleaseResult
Required. Array of the subtransactions to be updated.
Successful
Required. Publication status of the subtransaction. You can specify the value as true or false. Default is false.
To update the publication status of the subtransaction as Succeeded in Windchill, specify the value as true. To update the status of the subtransaction as Failed, specify the value as false.
ObjectDescription
Optional. Description of the object in the subtransaction; it should preferably be the object number.
Action
Required. You can specify the value as Create, Change, or Delete. The value is case-insensitive.
ObjectID
Required. The OID of the persistable Windchill object that was released.
TargetID
Required. The ID of the distribution target that the Windchill object was released to; it uniquely identifies the target system and the organization destination.
Class
Required. The type of object that the RPC is associated with (for example, com.ptc.windchill.esi.BOMHeader). For details on class values, see “ESI Response Meta Information File” specified on the target.
Message
Optional. The message that indicates the reason for the Succeeded or Failed status for the subtransaction.
* 
To successfully update the status of a transaction as Succeeded, the value of the Successful attribute for each subtransaction passed in the PostResultForTransactionAndSubtransaction action must be true.
Example: Updating the Status of Multiple Subtransactions to Successfully Publish the Transaction
The following example shows you how to update the status of each of the two subtransactions in a transaction to publish the transaction for the specified primary Windchill object. In this example, the primary Windchill object is a part, and the distribution target in each subtransaction is associated with the part. In this example, the transaction status is updated as Succeeded, as the status of each subtransaction specified in the request body is true.
Use the following POST URI with the request body:
URI
POST /Windchill/servlet/odata/ESI/PostResultForTransactionAndSubtransaction
Request Headers
Content-Type: application/json
CSRF_NONCE: <Use the value from Fetch NONCE example>
Request Body
{
"TransactionID": "11",
"Message": "Success in publishing 0000000001, VMP-001, Demo Organization, A.2 (Design)",
"PrimaryBuisnessObjectID": "OR:wt.part.WTPart:114570",
"ReleaseResult": [
{
"Message": "Success in Publishing SubTxn1",
"ObjectDescription": "Part",
"Successful": true,
"TargetID": "00000003",
"ObjectID": "OR:wt.part.WTPart:114570",
"Class": "com.ptc.windchill.esi.Part",
"Action": {
"Value": "Create"
}
},
{
"Message": "Success in Publishing SubTxn2",
"ObjectDescription": "Part",
"Successful": true,
"TargetID": "00000006",
"ObjectID": "OR:wt.part.WTPart:114570",
"Class": "com.ptc.windchill.esi.Part",
"Action": {
"Value": "Create"
}
}
]
}
Example: Updating the Status of Multiple Subtransactions in a Transaction
The following example shows you how to update the status of two subtransactions in a transaction. In this example, the status of one subtransaction is specified as false, and the status of the second subtransaction is specified as true in the request body.
Use the following POST URI with the request body:
URI
POST /Windchill/servlet/odata/ESI/PostResultForSubTransaction
Request Headers
Content-Type: application/json
CSRF_NONCE: <Use the value from Fetch NONCE example>
Request Body
{
"TransactionID": "11",
"ReleaseResult": [
{
"Message": "Failure in Publishing SubTxn1",
"ObjectDescription": "Part",
"Successful": false,
"TargetID": "00000003",
"ObjectID": "OR:wt.part.WTPart:114570",
"Class": "com.ptc.windchill.esi.Part",
"Action": {
"Value": "Create"
}
},
{
"Message": "Success in Publishing SubTxn2",
"ObjectDescription": "Part",
"Successful": true,
"TargetID": "00000006",
"ObjectID": "OR:wt.part.WTPart:114570",
"Class": "com.ptc.windchill.esi.Part",
"Action": {
"Value": "Create"
}
}
]
}
The request updates the status of the first subtransaction as Failed and that of the second subtransaction as Succeeded.
Example: Updating the Status of a Transaction
The following example shows you how to update the status of a transaction. In this example, the status of the transaction is updated as Succeeded.
Use the following POST URI with the request body:
URI
POST /Windchill/servlet/odata/ESI/PostResultForTransaction
Request Headers
Content-Type: application/json
CSRF_NONCE: <Use the value from Fetch NONCE example>
Request Body
{
"TransactionID": "11",
"Message": "Success in publishing 0000000001, VMP-001, Demo Organization, A.2 (Design)",
"PrimaryBuisnessObjectID": "OR:wt.part.WTPart:114570",
"Successful": true
}