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.

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);
        }
    }
}