Conditional Carrying counter

0
I have two entity E1= Fruits(IndexNo, Name)E2 = Counter(count)I have four different pagesEach pages have two buttons "YES" & 'NO'On Page1 if I pressed "YES" Button it has to increase "count" value by 1 and go to page2 with count =1 and if preesed "NO" just it goes to page2 on Page2 if pressed "YES" it has to increament count value by +2 (i.e now count =3) and go to page3 by carrying count value . If preesed "No" it has to simply go to page3 with its previous value to count.same for page3 on page4 I have to match the Count value with indexNo and show it respective Name(FruitName)How should I implement my requirement please help me .
asked
2 answers
0

Use a non persistent helper object as parameter on the pages. In this helper object you can store the count values. Now on the buttons use a nano or microflow to adjust the counters and open the next page passing the non persistent helper object again as parameter. This way in the end you have the correct values because you pass the object along in the process which hold the current count.

Regards,

Ronald



answered
0

hi,

Correct Design (Do NOT use separate Counter entity)

You do not need two entities.

Instead:

1.Use ONE Non-Persistent entity

Example: WizardContext

Attributes:

  • Count (Integer)

Pass this same object across all 4 pages.

Page Flow Implementation

Page 1

Button YES → Microflow:

  • Change Object → Count = $WizardContext/Count + 1
  • Show Page 2 (pass same object)

Button NO → Show Page 2 (no change)

Page 2

Button YES → Microflow:

  • Change Object → Count = $WizardContext/Count + 2
  • Show Page 3 (pass same object)

Button NO → Show Page 3 (no change)

Page 3

Same pattern.

Page 4 (Match with Fruits)

Add a Data View or Microflow:

Retrieve Fruits with XPath:


[ IndexNo = $WizardContext/Count ]

Display the Name.

Best Practices

  • Use Non-Persistent entity for wizard-like flow
  • Always pass the same object between pages
  • Do NOT create new Counter objects per page
  • Do NOT commit until final step (if needed)

Why This Works

Mendix passes objects by reference between pages.

As long as you pass the same object, the updated count is carried forward automatically.

Short Answer:

Use one Non-Persistent context object, update Count in microflows, pass it to next page, and on final page retrieve Fruit using XPath [IndexNo = $Count].


answered