Documente Academic
Documente Profesional
Documente Cultură
This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are
protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy,
reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any
means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited.
The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please
report them to us in writing.
If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S.
Government, the following notice is applicable:
U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software, any programs installed on the
hardware, and/or documentation, delivered to U.S. Government end users are “commercial computer software” pursuant to the applicable
Federal Acquisition Regulation and agency-specific supplemental regulations. As such, use, duplication, disclosure, modification, and
adaptation of the programs, including any operating system, integrated software, any programs installed on the hardware, and/or
documentation, shall be subject to license terms and license restrictions applicable to the programs. No other rights are granted to the U.S.
Government.
This software or hardware is developed for general use in a variety of information management applications. It is not developed or intended
for use in any inherently dangerous applications, including applications that may create a risk of personal injury. If you use this software or
hardware in dangerous applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures
to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software or hardware
in dangerous applications.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and are
trademarks or registered trademarks of SPARC International, Inc. AMD, Opteron, the AMD logo, and the AMD Opteron logo are
trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group.
This software or hardware and documentation may provide access to or information on content, products, and services from third parties.
Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party
content, products, and services. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due to
your access to or use of third-party content, products, or services.
Documentation Accessibility
For information about Oracle's commitment to accessibility, visit the Oracle Accessibility Program website at
http://www.oracle.com/pls/topic/lookup?ctx=acc&id=docacc.
Overview.............................................................................................................................................5
Example Actions That Order Management Extensions Can Perform........................................6
Using Order Management Extensions to Update the Order Submit Date: Worked Example.........29
Defining Extensions That Modify Order Management Cloud 3
Test Your Work.........................................................................................................................30
Using Order Management Extensions to Verify Data That Users Enter: Worked Example..........34
8 Methods You Can Use with Order Management Extensions: Reference................................35
Logger Method.................................................................................................................................36
Message Method...............................................................................................................................36
Specifying Message Name and Tokens....................................................................................36
Creating Messages for Sales Orders and Sales Order Lines.....................................................37
List of Attributes...............................................................................................................................43
Overview
Starting in Release 11.13.17.05.0 (Release 13, Update 17B) of Order Management Cloud, you can use the
Manage Extensions page in the Setup and Maintenance work area to write your own Groovy script that
modifies your Order Management deployment, and to specify the extension point that determines when to
run this script.
An order management extension is a Groovy script you write that meets your specific business
requirements. An extension point is an event that you specify to determine when to run this script.
You can use a flexfield to modify the data model, or Page Composer to modify the user interface, but you
cannot use them to programmatically modify logic or modify your order management deployment.
Instead, you can use an order management extension.
The following Groovy script is an example of an order management extension named Update Order
Submit Date. It uses the _H1AttributeDateTime attribute so it can set the value of an extensible flexfield to
the date and time when Order Management submitted the sales order.
Example Business
Description
Requirement
Action Description
Submit a sales order The following are examples of order management extensions:
Reassign the warehouse for pick-to-order. You define an item that
determines whether the sales order references a pick-to-order or a
hardware model.
Stop support lines that reference an incorrect accounting rule. You
can define item entities and accounting rule entities.
Make sure only one contract is Active or Signed for a booking. You
can define entities for the installed base, contracts, or order
Action Description
management.
Assign a sales representative. You can define sales compensation
rules.
Update the accounting rule for a model for included items.
Update the quote status for each sales order from a storefront that a
third-party partner maintains.
Part Description
A Groovy function, similar to a Java function, such as getAttr. You can use a
Function function only in the extension where you define it. You cannot define a
function in one extension, and then use it in another extension.
Message A message that you send to Order Management and that can display in the
Order Management work area. Note the following points:
An extension can log an error or warning message in the messaging
framework.
Order Management logs each message in a log file as part of order
import or when a web service rejects a sales order.
An error message stops the flow and rejects the save or submit action.
A warning allows the flow to continue. If you use a warning at the
beginning of a submission request, then Order Management displays the
Part Description
Import
Source
Order
6 5 4 3
On End of Process On Start of
Fulfill Sales Lock Sales
Submission Submission Submission
Order Order
Request Request Request
Legend
Explanation of Callouts
You can run an extension at an extension point when creating a sales order:
1. Something occurs that triggers the On Save event:
An Order Entry Specialist performs an action in Order Management that causes one of the
following implicit saves to occur:
Validate
Save
Save and Close
Validate
Reprice
Submit
Copy Order
Create Revision
Create Return
Order Management Cloud imports a source order from a source system, and then processes it,
such as creating cross-references, defaulting values, and so on.
2. You can create an extension that runs on the On Save event.
3. You can create an extension that runs on the On Start of Submission Request extension point. If the
extension results in failure, then Order Management sets the sales order status to Draft, with errors.
4. Order Management processes the submission request, including running validations, performing a
credit check, communicating with Global Trade Management, and so on.
5. You can create an extension that runs on the On End of Submission Request extension point. If the
extension results in:
Failure. Order Management sets the sales order status to Draft, with errors.
Warning. Order Management displays a warning message, successfully submits the sales order,
and continues to process it through order fulfillment. The Order Entry Specialist can examine the
warning messages on the submitted order.
6. The fulfillment system fulfills the sales order, including shipping, invoicing, and so on. You cannot
run an extension during order fulfillment.
On Save
If an order management extension that runs during On Save raises a validation failure, then Order
Management stops running the extension and moves control to the next extension that you specify to run
during On Save. If the validation failure includes at least one error message, and if Order Management has
already run each of the On Save extensions, then it aborts the save for the sales order.
Order Management handles each message that the extension raises differently depending on how it is
saving the sales order:
An Order Entry Specialist is saving a sales order in the Order Management work area. Order
Management displays the message in a dialog. This user must correct the validation error and attempt
to save the sales order again.
A service is saving a source order during order import. Order Management returns the message in a
response. The channel that is importing the source order must fix it, and then import it again.
Order Management does not save the message in the messaging framework because it might not have
saved the sales order and the change that caused the validation to fail.
For example:
Action Format
Code Description
def soldToPartyName =
Get the value of the BuyingPartyName attribute.
header.getAttribute("BuyingPartyName");
Code Description
def quantity =
line.getAttribute("OrderedQuantity"); Get the value of the ordered quantity.
}
Code Description
Get the row set for the order charges of the child
def charges = line.getAttribute("OrderCharges");
entity.
def charge = charges.next(); Get the next order charge from the row set.
def chargeComps = Get the row set for the charge components of the
charge.getAttribute("ChargeComponents"); child entity.
def currency =
chargeComp.getAttribute("ChargeCurrencyCode Get the value of the ChargeCurrencyCode attribute
"); from the current charge component row.
17. }
18. }
19. }
Code Description
def lines = header.getAttribute("Lines"); Get the row set for the order lines.
Table 10. Example of Calling a Web Service, Call the Web Service
Code Description
void allocateSalesCredits(def line, String
itemNumber) {
Get the handle that you use to call the web service.
def serviceInvoker =
context.getServiceInvoker();
Code Description
"</ns1:GetSalesCreditAllocation>";
def salesCredits = Get the row set for the sales credit from the current
line.getAttribute("SalesCredits"); line.
sc.setAttribute("Percent", new
Set the value for the percent allocation attribute.
BigDecimal(percent));
salesCredits.insertRow(salesCredit);
Insert the new row in the row set.
}
Code Description
Code Description
else
return false
}
order management extension that calls an API on the context object so that it queries the table and
accesses the public view objects that the table contains.
You must specify the complete definition name of the view object. The following example extension
accesses a view object.
Table 12. Example of Accessing Data from Other Oracle Fusion Entities
Code Description
Code Description
def lines = header.getAttribute("Lines"); Get the row set for the order lines.
def line = lines.next(); Get the next line and assign it to the variable line.
def inventoryItemId = Get the inventory item Id for the item from the
line.getAttribute("ProductIdentifier"); order line that the Order Entry Specialist selected.
def orgId =
Get the organization for the item from the order
line.getAttribute("InventoryOrganizationIdentifi
line that the Order Entry Specialist selected.
er");
Table 14. Example of Filtering Results, Defining the Public View Object
Code Description
Object getItem(Long itemId, Long orgId) { Create an instance of the public view object for the
def itemPVO = item.
context.getViewObject("oracle.apps.scm.product
Code Description
Model.items.publicView.ItemPVO");
def rowset = itemPVO.findByViewCriteria(vc, Define the view criteria that filters the rows when
-1); you query the view object.
def item = rowset.first(); Get the first item row that meets the condition.
vcrow.setAttribute("OrganizationId", orgId);
def rowset = itemPVO.findByViewCriteria(vc, -1);
def item = rowset.first();
return item;
}
To raise a validation error, Order Management creates a validation exception, stops running the extension
that failed, and then runs any subsequent extensions for this extension point that you define. Order
Management accumulates each message that it creates from validation exceptions for all the extensions
that it runs during the extension point, and then displays them together to the Order Entry Specialist or, if
it is a source order from a source system, then it returns them through a service call in the response to the
caller.
If Order Management creates a validation exception, then your extension code must send a message that
describes the cause of the failure. You must do one of the following:
Code the message text in your order management extension. You must specify Distributed Order
Orchestration as the application for this message. Order Management will display this text in the
Order Management work area without modification.
Code your order management extension so that it sends the name of an Oracle Fusion message
and the message parameters. Order Management will get the message from the Oracle Fusion
message repository, populate any message tokens that the message references, display the message in
the Order Management work area, and then add it to the message log. You can use the Manage
Messages page to define a message.
This topic frequently mentions ValidationException. For details, see ValidationException Method.
Code Description
import
oracle.apps.scm.doo.common.extensions.Validat Import the ValidationException class.
ionException;
def salesCredits = Get the row set for the sales credits that the order
header.getAttribute("SalesCredits"); header specifies.
Code Description
if( "1".equals(salesCredit.getAttribute("SalesCre
ditTypeCode")) ) Determine whether the sales credit is a revenue
percent.
def percent =
Get the percent allocation of the sales credit.
salesCredit.getAttribute("Percent");
Code Description
def salesCredits = Get the row set for the sales credits that the order
header.getAttribute("SalesCredits"); header references.
def percent =
Get the percent allocation of the sales credit.
salesCredit.getAttribute("Percent");
Code Description
Use the SEVERE logging level only for extremely important conditions, such as a read error
condition. Logging all events as SEVERE will produce a large number of log messages and degrade
performance.
Use the FINEST logging level to get detailed reporting. It is recommended that you use FINEST for
entry and exit logging. The Logger Method can write logs at different levels.
Avoid concatenating strings. If your log statement must concatenate strings, then write your code so
that it makes sure logging for the targeted logging level is enabled before you perform the
concatenation. Use the Logger Method to avoid code readability problems that sometimes occur when
you write code that makes sure the logging level is enabled, and when you include this code for every
log statement. The Logger Method provides an alternative way to log for each level. It can use a
format string and parameters as input. It can substitute the parameters in the format string only if the
logging is enabled at the targeted level before writing to the log. This approach postpones string
manipulation until your code confirms that logging is enabled.
For details about how to set log levels, see java.util.logging.Level on the Java™ Platform, Standard
Edition 7 API Specification website at
https://docs.oracle.com/javase/7/docs/api/java/util/logging/Level.html.
Code Description
Table 18. Example of Writing Messages to Logs, Define the Public View Object
Code Description
Object getItem(Long itemId, Long orgId, def
logger) {
logger.logFiner("Entering method getItem"); Create an instance of a public view object named
def itemPVO = Item. Specify to log at the FINER level.
context.getViewObject("oracle.apps.scm.product
Model.items.publicView.ItemPVO");
def rowset = itemPVO.findByViewCriteria(vc, Specify the view criteria to filter rows and query
-1); the view object.
def item = rowset.first(); Get the first item row that matches the condition.
86. }
87. Object getItem(Long itemId, Long orgId, def logger) {
88. logger.logFiner("Entering method getItem");
89. def itemPVO =
context.getViewObject("oracle.apps.scm.productModel.items.publicView.
ItemPVO");
90. def vc = itemPVO.createViewCriteria();
91. def vcrow = vc.createViewCriteriaRow();
92. vcrow.setAttribute("InventoryItemId", itemId);
93. vcrow.setAttribute("OrganizationId", orgId);
94. def rowset = itemPVO.findByViewCriteria(vc, -1);
95. def item = rowset.first();
96. logger.logFiner("Exiting method getItem: itemNumber %s",
item.getAttribute("ItemNumber"));
97. return item;
98. }
7 Applied Examples
This chapter includes applied examples that describe how to you can use order management extensions to
meet your specific business requirements.
Some of these examples import classes from Oracle Trading Community Architecture only for
demonstration purposes. The import structure you use depends on the architecture that you reference
in your environment.
Attribute Value
Name H1AttributeDateTime1
Context HeaderContext1
For details about how to create an extensible flexfield, see Configuring Extensible Flexfields in Order
Management: Explained.
2. In the Navigator, click Setup and Maintenance.
3. On the Setup and Maintenance page, click Order Management, and then click Setup.
4. On the Setup page, search for, and then open Manage Order Management Extensions.
5. Notice that the Manage Order Management Extensions page includes the following elements:
Three tabs, one for each extension point.
A Sequence column. Order Management runs the extensions for each extension point
sequentially according to the values in the Sequence column. For example, if the first row
contains a value of 10, the second row a value of 30, and the third row a value of 20, then Order
Management will run row one, row three, and then row two.
6. On the Manage Order Management Extensions page, Click Actions, and then click Create New.
7. In the Create Extension dialog, accept the default values, and then click OK.
The Use Existing option creates a reference to an extension that already exists. It does not create a
copy. For example, assume an extension named My_Extension already exists on the On Save
extension point. Assume you set Use Existing to My_Extension when you create an extension on the
On Start of Submission Request extension point. If you modify My_Extension from On Start of
Submission Request at any point in the future, then Order Management will automatically update
My_Extension for On Save with your modification. If you modify My_Extension for On Save, then
Order Management will update My_Extension for On Start of Submission Request.
8. On the Create Extension page, enter the following values.
Attribute Value
Attribute Value
Attribute Value
Attribute Value
114. // Make sure the extension runs only for your test sales order.
If multiple developers use your test environment, then this
condition makes sure the code updates only your sales order. You
must remove this condition in a production environment.
115. def poNumber = header.getAttribute("CustomerPONumber" );
116. if(poNumber == null) return;
117. if( !poNumber.startsWith("MatchRelationship") ) return;
118. boolean relationExists=false;
119.
120. //define the variables you will use to store the identifiers.
121. def soldTo = header.getAttribute("BuyingPartyIdentifier")
122. def billTo = header.getAttribute("BillToCustomerIdentifier")
123.
124. //if the relationship exists, then further validation is not
necessary, so save the sales order, and then exit.
125. if
(header.getAttribute("BuyingPartyName")==header.getAttribute("BillTo
CustomerName"))
126. relationExists=true;
127.
128. //determine what relationship currently exists between the
bill-to customer and the sold-to customer.
129. //reference the view object that stores the relationship. In
this example, the CustomerAccountRelationship view object stores
this relationship.
130. def CustPVO =
context.getViewObject("oracle.apps.cdm.foundation.parties.publicView
.customerAccounts.CustomerAccountRelationshipPVO");
131.
132. //create the view criteria.
133. def vc = CustPVO.createViewCriteria();
134. def vcrow = vc.createViewCriteriaRow();
135. //RelatedCustAccountId is an attribute that stores the sold-to
relationship, so you set vcrow to reference RelatedCustAccountId.
You will examine it to determine whether the sold-to customer is
related to the bill-to customer.
136. vcrow.setAttribute("RelatedCustAccountId", soldTo);
137. //Query the view object according to the criteria that you set
in the previous line of code.
138. def rowSet = CustPVO.findByViewCriteria(vc, -1);
139.
140. //Read through the row set. If a row exists that contains a
relationship, then you have determined that a relationship exists
between sold-to and bill-to, so save the sales order, and then exit.
141. while (rowSet.hasNext()) {
142. def row = rowSet.next();
143. def billtorelation=row.getAttribute("CustAccountId")
144. if (billtorelation == billTo)
145. {
146. relationExists=true;
147. }
148. }
149. //Create an exception when a relationship does not exist and
display an error message.
150. //header.setAttribute("ShippingInstructions",
header.getAttribute("ShippingInstructions") + ", " relationExists)
151.
152. if( !relationExists) {
153. throw new ValidationException("The order submit failed because the
bill-to customer is not related to the sold-to customer.");
154. }
Note that this example is only for demonstration purposes in a development environment. It hard codes the
message to display in the Order Management work area in the English language as The order submit failed
because the bill-to customer is not related to the sold-to customer. In general, to avoid problems with
translation to other languages, it is recommended that you not hard code the message in a production
environment, but instead use the following format to reference a message from the messaging framework:
throw new ValidationException("lookup_code", "message name", token_values);
where:
lookup_code determines where and how to display the message in the Order Management work
area. For example, you can reference multiple lookup codes to display messages in different pie slices
on the infolets in the Order Management work area, according to lookup code.
message name identifies the name of the message that exists in the messaging framework.
token_values specifies a list of the values to use in the tokens that the message contains. If the
message does not contain any tokens, then use null.
For example, use the following code to display the contents of the FOM_CMN_INV_BILL_TO message:
throw new ValidationException("ORA_MANAGE_EXTENSIONS", "FOM_CMN_INV_BILL_TO", null);
For details about using lookup_code, see ValidationException Method.
Attribute Value
ValidateRelationshipsBetweenAttributes
Purchase Order
_run_extension
2. Verify that the error dialog displays the message you hard-coded.
Note that Computer Service and Rentals is the sold-to customer, Business World Inc is the bill-to
customer, they do not match, so Order Management displays an error.
3. Set the following value, and then click Submit.
Attribute Value
4. Verify that Order Management submits the sales order and sets the status to Processing.
Note that Computer Service and Rentals is the sold-to customer and the bill-to customer, they match,
so Order Management processes the sales order.
Attribute Value
Parameter Description
Parameter Description
Logger Method
The Logger method returns the message log. It uses the following format:
logFine(String msg)
where:
logFine. Identifies the name of the log file.
Message Method
The Message method uses a message type and message text to create a message for the sales order. It uses
the ORA_MANAGE_EXTENSIONS request function to log messages, by default. It uses the following
format:
Message(MessageType messageType, String messageText)
where:
messageType. Type of message. You can use one of the following values:
Message.MessageType.ERROR or Message.MessageType.WARNING.
messageText. Text of the message to display.
Parameter Description
Creates a new row. If the entity does not support creating a new row,
createRow() then this parameter returns an error message when your extension
calls this method.
Inserts the row into the current iterator, where row specifies the row
number to insert.
insertRow(Row row)
Use this method to add a new row to the iterator after you create the
iterator.
MANAGE_HOLD Hold.
ORA_VALD_CONFIG Configuration.
ORA_VALD_PRICING Pricing.
ORA_VALD_PAYMENT Payment.
Use the following format to include an array of variable names and values:
on each fulfillment
line
Payment Yes No No
Item master No No No
Customer master No No No
Document reference No No No
List of Attributes
Use the following file to get a list of the attributes that each extension can access.
Order Entities
available in Extensions.xlsx