How to access attribute name of an entity in microflow?

0
I am retrieving  an entity into a list in a microflow, now I want to access the attribute name of that entity. So how can I get that attribute name in microflow? For example:- I have entity “Customer”, which have attributes as “Name”,”Price”. Now let say I want to print the attribute name of “Price” ,i.e, “Price”. So how can I do that?
asked
4 answers
1

If you retrieve a list then you have a few options to access values

 

  1. you want an aggregation of values; 
    Use the aggregation activity which uses the returned list, set aggregation type and attribute 
  2. You want to have the value of an attribute of each individual object in the list
    Add a loop and iterate over the list. Use the $Iterartor{EntityName}/{RequiredAttribute} to access the value
  3. You retrieve a list, but its actually a single object, i.e. the customer of an order
    Set range to first (instead of all) and use the output ${VariableName}/{RequiredAttribute}

 

 

answered
2

You can do that with the marketplace module ModelReflection.


EDIT 1:

You need a java-action for that. (Read the Eclipse introduction)

  1. Create a non persistent object called AttributeName with one attribute Name
  2. Create a java-action called JA_GetMembers, add a typed parameter called Anyobject
  3. In general, add a parameter called Anyobject , type object, AnyObject
  4. Return type is list of AttributeName
  5. Project/Deploy for eclipse

 

add this code at BEGIN USER CODE

		// BEGIN USER CODE
		ArrayList<IMendixObject> list = new ArrayList<IMendixObject>();
		Collection<? extends IMendixObjectMember<?>> members = Anyobject.getMembers(getContext()).values();
		for( IMendixObjectMember<?> member : members ) {
			String attributeName = member.getName();
			if(!attributeName.startsWith("System.") && !attributeName.equals("changedDate") && !attributeName.equals("createdDate")) {						
				AttributeName aName = new AttributeName(getContext());
				aName.setName(getContext(), attributeName);
				list.add(aName.getMendixObject());
			}

		}
		return list;
		// END USER CODE

 

Eclipse will show a readline below missing imports, click on it and always choose ‘Import.xyz’

 

In your microflow take the head of the list and pass that object to the Java-action. The result list will contain the names.

 

Otherwise take a look at CopyAttributes from communitycommons.

answered
0

You can first take head element of list that will  give you first object of list and pass that object to show page activity.(page should use data view to show object detail).

answered
0

Sorry for my complex answer.

“ I just need to capture the Attribute Name in a microflow variable or print it in log message. “

 

https://docs.mendix.com/refguide/loop

https://docs.mendix.com/refguide/log-message

 

 

answered