Access List Member using the value of a variable

1
I have different member in a list and a variable which have some value. I am accessing these list members in a loop but I have to print the value of a member if the member’s name is equal to variable value. Basically if I want to access member’s dynamically based on the value of that variable using micro
asked
3 answers
1

Hi Mukesh,

If I understand correctly, you want to find an object in a list, based on the value of a attribute, right? Perhaps you can use the list operation “find” for this?

Hope this helps!

answered
0

You may need to drop into Java and do this in a Java Action. Assuming you want to return a string, something like this should work. attributeName will the String representation of the attribute name you want the value for.
 

return (java.lang.String) getMendixObject().getValue(getContext(), attributeName);

 

You will need to call this action in a loop as you iterate over each object in the list. Once you have a match, you can add it to a new list and once you’ve finished the loop you’ll have a list of matching objects.

answered
0

Another approach is to build an OQL query using that variable value, that way it will select only that attribute

answered