Soft Attributes for Orders
You can add soft attributes for orders to add more order details.
Follow these steps to create a soft attribute orderAttribute for including additional details for orders:
1. Log into Servigistics InService administration home page URL as an administrator.
2. On the administration home page, click Attributes.
3. On the Types panel, click Shopping Cart, if not already selected by default.
4. On the Attributes panel, click Create Attribute.
5. Enter the internal name, data type, display name, and description for the soft attribute orderAttribute and click Apply.
6. Open the DefaultCommerceDelegate.java file located in the directory <INS_ HOME>InS_SW/SW/Applications/Windchill.ear/codebase.war /com/ptc/sc/services/plugins.
7. Add the following code for the soft attribute orderAttribute in the placeOrder method of the DefaultCommerceDelegate Java class.
// Following imports are required
import java.util.Map;
import java.util.HashMap;
import com.ptc.core.lwc.server.PersistableAdapter;
import com.ptc.core.meta.common.OperationIdentifier;
import com.ptc.core.meta.common.OperationIdentifierConstants;
import com.ptc.c ore.meta.common.TypeInstanceIdentifier;
// Default implementation does nothing.
String responsePONumber = "PONumber Test"; //Modify according to your use case
Map<String, Object> existingAttrs = orderObj.getTypedAttrs();
if (existingAttrs == null) {
existingAttrs = new HashMap<String, Object>();
existingAttrs.put("orderAttribute", responsePONumber);
orderObj.setTypedAttrs(existingAttrs);
return orderObj;
}
existingAttrs.put("orderAttribute", responsePONumber);
return orderObj;
8. Open the details.html file located in the directory <INS_ HOME>InS_SW/SW/Applications/Windchill.ear/codebase.war/delivery/app/views/orderDetails.
9. Add the following input field details for the soft attribute orderAttribute in the details.html file:
<div class='attributeInfo'>
<span data-ng-bind="::'ORDER_NAME' | translate"></span>
<span data-ng-bind="::context.currentNode.attributes.orderAttribute"></span>
</div>
The soft attribute orderAttribute is displayed on the Details page for a order:
In the following JSON file, the POST request result for an order contains the soft attribute orderAttribute :