Use Order Management Extensions to Get Values from Extensible Flexfields
Use the getOrCreateContextRow method to add new data or update data through a flexfield. Use getContextRow to get data that you already added.
Use getOrCreateContextRow("context code")
or
getAttribute("API name")
, where context code
is the name of the context code of the extensible flexfield and API
name
is the name of the API (application programming interface) that
you use to call the method:
Entity |
Value to Use in Code |
Parent |
Read During All Events |
Write During Save or Start of Submission Request |
Write During End of Submission Request |
---|---|---|---|---|---|
Extensible flexfield on order header |
Not applicable |
Header |
Yes |
Yes |
Yes |
Extensible flexfield on fulfillment line |
Not applicable |
Lines |
Yes |
Yes |
Yes |
If you use an extension to get a value from an extensible flexfield, then the extension behaves differently depending on the method that you use and whether the context that you specify in the extension exists.
Method | If the Context Doesn't Exist |
---|---|
getContextRow("EFFContextName") | This method doesn't create a new context. |
getorCreateContextRow("EFFContextName") | This method creates a new context. |
Assume you use this code.
import oracle.apps.scm.doo.common.extensions.ValidationException;
def poNumber = header.getAttribute("CustomerPONumber");
if (poNumber != null && poNumber.equals("test")) {
def lines = header.getAttribute("Lines");
while (lines.hasNext()) {
def line = lines.next();
def context = line.getOrCreateContextRow("My_Context");
def effVal = context.getAttribute("eligibleforprime");
// throw new ValidationException("Eff value effVal:: "+effVal);
if (effVal.equals("Y")) {
line.setAttribute("OrderedQuantity", 0);
}
}
}
where
getOrCreateContextRow("My_Context")
attempts to find a context named My_Context. If that context doesn't exist, then the extension creates it.
You use getOrCreateContextRow to add new data or to update data through the flexfield on your sales order.
If you only need to get data that you already added through the flexfield on the sales order, then use getContextRow instead of getOrCreateContextRow. For example:
import oracle.apps.scm.doo.common.extensions.ValidationException;
def poNumber = header.getAttribute("CustomerPONumber");
if (poNumber != null && poNumber.equals("test")) {
def lines = header.getAttribute("Lines");
while (lines.hasNext()) {
def line = lines.next();
def context = line.getContextRow("My_Context");
if (context == null) {
return; // if we don't find a context, then don't create one.
}
def effVal = context.getAttribute("eligibleforprime");
// throw new ValidationException("Eff value effVal:: "+effVal);
if (effVal.equals("Y")) {
line.setAttribute("OrderedQuantity", 0);
}
}
}
Make Sure the Context Exists
If you use getOrCreateContextRow, then you must make sure the context exists. Assume you use this code:
def cntxRow = header.getOrCreateContextRow("HeaderContext1");
cntxRow.setAttribute("_H1AttributeChar2", docRef.getAttribute("DocumentNumber"));
If the context doesn't exist, then you'll create an empty record.
getContextRow returns null
when the context doesn't exist. You can
use it to test for a null condition before you do an action. For example:
def context = line.getContextRow("VS_Context");
def effVal = context != null ? context.getAttribute("eligibleforprime") : null;
if("Y".equals(effVal)) {
// Do something here.
}
Use One Extension for Your Context
Use only one extension to populate your context. Don't use more than one extension to do this. Assume you have these extensions:
Set Packing Note Extension
def notes = line.getOrCreateContextRow("Line Level Notes");
notes.setAttribute("packNote", "Packing Instructions 22");
Set Shipping Note Extension
def notes = line.getOrCreateContextRow("Line Level Notes");
notes.setAttribute("shipNote", "Shipping Instructions 11");
Populating the Line Level Notes context in more than one extension might affect performance. Instead, use only one extension:
Set Packing and Shipping Notes Extension
def notes = line.getOrCreateContextRow("Line Level Notes");
notes.setAttribute("packNote", "Packing Instructions 22");
notes.setAttribute("shipNote", "Shipping Instructions 11");