Sterling OMS Template Customization
Sterling OMS Template Customization
Different Ways to Override Template for API/Service
- Overriding the template file
- Applying template at Service Configuration Level
- Override template using Java / XSLT program
How to override createOrder API output ?
Did you notice when you call create order API the result will have only 4 attributes ? (as shown below). How do we override the output ?
<Order EnterpriseCode="" OrderHeaderKey="" DocumentType="" OrderNo=""/>
- Copy the file from <OMS Install Dir>\repository\xapi\template\merged\api\createOrder.xml to <OMS Install Dir>\extensions\global\template\api\createOrder.xml
- Edit the newly copied file (createOrder.xml) and add the Elements as you needed
<Order EnterpriseCode="" OrderHeaderKey="" DocumentType="" OrderNo=""> <OrderLines> <OrderLine /> </OrderLines> </Order>
- Build Resource jar by running command from OMS bin folder deployer.cmd -t resourcejar
- Perform build and deploy
- Call the createOrder API using API tester to see the result
How to get Extended Column value part of getItemDetails API ?
- How to add/extend column read this link
- Copy the file from <OMS Install Dir>\repository\xapi\template\merged\api\getItemDetails.xml to <OMS Install Dir>\extensions\global\template\api\getItemDetails.xml
- Edit newly copied file (getItemDetails.xml) and add <Extn /> as shown <Item></Extn /></Item>
- Build Resource jar by running command from OMS bin folder deployer.cmd -t resourcejar
- Perform build and deploy
- Call getItemDetails using API tester with below input and without any template
<Item ItemID="DEMO" OrganizationCode="Matrix" UnitOfMeasure="EACH" />
- Output contains <Extn /> in the result
How to apply template for custom table ?
- How to create custom table read this link
- Lets assume we had created XYZ_STUDENT custom table
- Create <OMS Install Dir>\extensions\global\template\api\createStudent.xml with below XML
<?xml version="1.0" encoding="UTF-8"?> <Student Active=" " FirstName=" " LastName=" " StudentID=" "/>
- Build Resource jar by running command from OMS bin folder deployer.cmd -t resourcejar
- Perform build and deploy
- Configure new sync service createStudent with Extended Database API (Drop down select createStudent)
- Call createStudent service using API tester with below input and without any template
<?xml version="1.0" encoding="UTF-8"?>
<Student Active="Y"
FirstName="Active" LastName="Kite" Lockid=" " Modifyprogid=" " Modifyts=" "
Modifyuserid=" " />
- Result contains only 4 attributes as given part of output template
Applying template at Service Configuration Level
For any API, template can be overridden using below configuration method.
Applying Template Using Java Program
setApiTemplate and clearApiTemplate methods called from env object
private boolean isPaymentProcessRequired(YFSEnvironment env, String enterpriseCd)
throws Exception {
env.setApiTemplate("getOrganizationList", getOrganizationOutputTemplate(enterpriseCd));
Document outputDoc = getApi().invoke(env, "getOrganizationList",
getOrganizationInput(enterpriseCd));
env.clearApiTemplate("getOrganizationList");
return paymentProcessRequired(outputDoc);
}
private Document getOrganizationOutputTemplate(String orgCode) {
YFCElement organization = YFCDocument.createDocument("Organization")
.getDocumentElement();
organization.setAttribute("OrganizationCode", orgCode);
return organization.getOwnerDocument().getDocument();
}
Event Template Customization
- Copy from INSTALL_DIR/repository/xapi/template/merged/event/ORDER_CREATE.ON_SUCCESS.xml to INSTALL_DIR/extensions/global/template/event/ORDER_CREATE.ON_SUCCESS.xml
- Edit the newly copied XML as per requirement (Add Attributes)
- Build Resource jar by running command from OMS bin folder deployer.cmd -t resourcejar
- Perform build and deploy
- Enable ON_SUCCESS event in CREATE_ORDER transaction
- Capture ON_SUCCESS event by adding action which contains YFS_EXPORT DB component (Testing Only)
- Call createOrder API using API tester
Interview Questions on Template Customization
- what are all the different argument available with setApiTemplate() method ? Answer :
- setApiTemplate(api_name, file)
- setApiTemplate(api_name,xmlDocument)
- When setApiTemplate(api_name, file) used what location file been picked from ? Answer : folder location INSTALL_DIR/extensions/global/template/api
- How to clear API template which set using Java Program ? Answer : clearApiTemplate(api_name)
- How to clear more than one API template ? Answer : env.clearApiTemplates()
- If template available in different places how the priority works ?
- setApiTemplate(file or Document) to YFSEnvironment Object (Priority 1)
- INSTALL_DIR/extensions/global/template/api/apiName.docType.xml (Priority 2)
- INSTALL_DIR/extensions/global/template/api/apiName.xml (Priority 3)
- If still not found apply the OOB template (INSTALL_DIR\repository\xapi\template\merged\api)
- How to override template for user exit ? Answer : Sorry Template override not applicable for user exits
Thanks for reading this post till the end. Please share your comments/feedback below. Any question you can write to as support@activekite.com
Please share this blog information to your friends. Lets learn together. Happy Learning !!!


very good and use full.
I have a scenario, if I need to get the stores around a particular zip code within radius of X km. How can we configure it in sterling and how can we fetch the stores
Kumar,
Please refer getSurroundingNodeList API. This is give you exactly you are looking for you. Keep learning !!!
Awsome!! very helpful for someone recently started working on Sterling..
How can, customize template for User Exit in sterling. If yes, how can we achieve it.
Please refer\xapidocs\code_examples\java\YPMGetItemPriceUEWCIntegrationImpl.java ( 3 files). This file has example how template can be used. Hope this helps !!!
How can I extend the event template for a custom transaction?