I got an email from colleagues of mine asking, “How can we use UDA function in Groovy?”
I was a bit surprised to hear that. Now, they did clarify that they want to use @UDA function in Data map/Smart Push.
I was half sure that it is not allowed. I still thought of making sure of that before I say anything 😉
Here are all the functions that are available while you create a Data Map.

Now, the question seems more appealing.
There are a lot of options available in Groovy, which can be used to perform operations using Metadata.
I decided to use a function called getMembersWithUda. This function gives you all the members that are associated with a certain UDA.
It is similar to @UDA(“Account”, “FXAccs”)
Groovy code for @UDA
def app=operation.application
def cube=app.getCube("EMG_PLN")
Boolean includeShared = false
def accountDim=app.getDimension("Account", cube)
// get all members associated with a uda in a dimension
def usrAccountEsbNames = accountDim.getMembersWithUda("FXAccs", includeShared, cube).collect{fixValues(it)}
def expandedAccountMbrs = usrAccountEsbNames.join(", ")
println("The following Account details were moved to reporting cube: \n ${expandedAccountMbrs}\n")

Similar to the other post on Data Maps, you can now use the expanded members to override the Data map Account source definition.
Let’s take this a bit further, shall we?
Can we now perform something like
@UDA(“Account”, “FXAccs”) AND @RELATIVE(“A6400”, 0)
Ooooh, that’s interesting.
Groovy code for @UDA AND @RELATIVE
/*RTPS: {AccountList}*/
def app=operation.application
def cube=app.getCube("EMG_PLN")
Boolean includeShared = false
def accountDim=app.getDimension("Account", cube)
// get uda associated members using a function
def usrAccountEsbNames = accountDim.getEvaluatedMembers("""Lvl0Descendants(${rtps.AccountList.toString()})""" as String, cube).findAll{it.hasUda("FXAccs")}.collect{fixValues(it)}
def expandedAccountMbrs = usrAccountEsbNames.join(", ")
println("The following Account details were moved to reporting cube: \n ${expandedAccountMbrs}\n")

We are expanding the members using the Lvl0Descendants function first on line 10. Once that is done, we are checking whether those members have got a UDA if it does then collect the Essbase member names as a List object.
All that happens with a single line of code!