on ‎2019 Sep 03 4:02 PM
Request clarification before answering.
Hi Jonas
You can do this with a short function:
import com.sap.it.api.mapping.*
def void filterAttributes(String[] attributes, String[] values, String[] attributeToLocate, Output output, MappingContext context) {
def searchFor = attributeToLocate[0]
def foundIndex = Arrays.asList(attributes).indexOf(searchFor)
def value = foundIndex == -1 ? "default value" : values[foundIndex]
output.addValue(value)
}
Wire it up like this:

Set the context of @attribute-id and custom-attribute to be the parent element (custom-attributes). The script assumes that the first two queues do not contain context changes.
The last parameter is the value of the attribute you are looking for.
Note that the script inserts a default value, if the attribute value could not be found. You can change this behaviour as needed.
Regards,
Morten
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Morten,
Updates: I modified the cardinality to 0..*. it's still giving me the same error.
Thanks for the script. I have one more question. What if I want to map short-description field based on lang what kind of change do I need to make? I have tried your script with the mapping, values of short-description are not passed to the custom function correctly.


| User | Count |
|---|---|
| 10 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.