getAttributeValueFromRequest()
This function can be used in a hook to get the value of a data attribute as available in the request. It must only be used in batch implementations. When a request arrives at a batch method implementation, it often must be forwarded to another method and/or business object, depending on the value for one or more attributes. This is also the case when using multiple implementations (so-called ‘chameleon’ implementations), see section Guidelines on Using or Setting Attribute Implementation Values.
function boolean getAttributeValueFromRequest(long i.request, string
i.path, ref string o.value)
Input:
- i.request: request provided as input in a before, on or after execute hook.
- i.path: the complete path to the attribute, starting from the top-level component (case-sensitive).
Output:
- return value: true if successful, false otherwise.
- o.value: the value of the data attribute, “” if return value is false.
Note:
- This function cannot handle qualifier attributes (xml attributes).
- This function will always return the value as a string. And it won’t work for complex content (xml).
- This function can only handle ‘leaf attributes’, so it cannot handle complex XML structures for ‘anyType’ attributes.
- For subcomponents this function will always return the value from the first instance.
Example of a before execute hook for a batch method implementation:
boolean retb
string order.status(12)
string amount(16)
retb = getAttributeValueFromRequest(i.request,
"Order.Header.StatusInformation.Status",
order.status)
if not retb then
| for example error if status is mandatory, or use a default order.status
...
endif
retb = getAttributeValueFromRequest(i.request,
"Order.OrderLine.Pricing.Price.Amount",
amount)
if not retb then
| for example error if amount is mandatory, or use a default amount
...
endif
if tolower$(order.status) <> "approved" or val(amount) < 10000.0 then
io.cancel = true
endif
return(0) | OK
In this case, the second getAttributeValueFromRequest() provides the amount from the first order line in the request.