XPath association - Mendix Forum

XPath association

1

Hi there,

I have an project entity associated with an controlling entity. A variable in the controlling entity will be

calculated throug a microflow. How can I set the association between the main and subentity in the retrieving action with xpath?

asked
7 answers
3

The '[%CurrentObject%]’ token can only be used in XPath constraints in the user interface. In microflows, you need to reference an object (and objects start with a $ sign).

 

Looking at your microflow, you will not be able to retrieve the data you want: you only have a Controlling_Eingang object at your disposal, and you try to retrieve a list of Controlling_Eingang. I don't know your domain model, but you either need to change your input object to the main entity (if Controlling_Eingang is your subentity), or you need to retrieve a list of your sub entity if (Controlling_Eingang is your main entity). If the start of your XPath constraint is correct, and the type of the list is correct, then you would need an input parameter of entity Project_Projektverwaltung.

 

Finally a suggestion on naming your entities: associations in Mendix are named EntityName1_EntityName2, so to easily distinguish associations from entities, you should avoid the _ symbol in the names of your entities.

answered
1

Hi Daniel,

To be honest, I don't have any idea what you are trying to achieve; but let me show an example how to model in Mendix.

Below I set the association to a Parent for all children without a Parent. I first retrieve the children, then set the association in a loop and finally commit that list to the database. Does this help?

Kind regards, Johan

answered
0

Allright, I see three options:

  1. Do not do anything, as the calculated attribute will be updated when you want to use it (display or whatever).
  2. Just commit the list of items you want to change, as the calculated attribute will also be recalculated on commit (I don't see the added value in this option wrt option 1).
  3. Recommended: do not use calculated attributes (as it always recalculates, so it’s performancewise often deprecated), but to model the calculation in the right flow: that is, when it should be calculated.

 

answered
0

I think to make my problem clear look for the following picture:

Now I want to automtically fill in the value attribute in controlling depending on the parent “Project”.

 

 

answered
0

Like this?

 

answered
0

To SET an association, you should CHANGE an object and let the association refer to another object. You are now using the RETRIEVE action, which does like Rom says.

answered
0

You cannot use current object here. Before you do this retreive, you have to make sure you have your project object available. THis can be done by first retrieve your project. Then you can that currentobject to that retreived object. 

answered