Rendering of addmore section or obsgroup is not working as expected when there are form conditions inside it

Hello everyone, In Froms2.0, when we have a section or obsgroup with add more property and there are form conditions inside them. If we do an add more instead of rendering the original state it is rendering the previous section state.

For example:- If we add a form condition for "prescribed days" mentioning it should display “missed days” only when some value is entered in “prescribed days”, the expected behavior when we add more is as shown in below picture

But the actual behavior now is as shown below where “missed days” is also displayed in newly added section

Proposed solution:- Write a method where it executes the whole form conditions script again when we click on add more and Should add a control event property for the section level, this is required because when there are multiple form conditions in a section then add more of that section fails to render fresh state

@angshuonline @snehabagri @sravya @swetha184 @vmalini @binduak @abhinavpc

1 Like

After having a discussion with Angshu we are going ahead to implement it by adding a control event property to section and obsgrp, which will be triggered on mount of section/obsgrp.

So, if I understand this right:

  1. for every “container” control (e.g. section, obsgroup etc) - an onload() function will be called on mount of the control
  2. if “add-more” is allowed for the control, and if so clicked on form for a container control - the control.onload() function will be called for the newly added control.
  3. These events are fired only for the control thats being added - and will have no effect or any other event being fired for either the parent control or sibling controls.

Yes Angshu, that is correct.

After a little more research, we have come to the following solution for add more section form conditions to work properly on render, on click of add more and when rendering with data:

  1. We will create a new api called “getFromParent(‘conceptName’)” - this will get the concept with the given name from the immediate parent of the control.
  2. We will also create "getFromParentById(‘control id’), which will do the same as above, with control id as parameter.

We can come up with a better name for ‘getFromParent’

In case of any concerns, do let us know @angshuonline @vinisha @shivarachakonda

Adding to above comment, there is an existing code which already hides all brother trees(all add more controls) like this.

setHidden(hidden) {
const brotherTrees = ControlRecordTreeMgr.getBrothers(this.rootRecord, this.currentRecord);

brotherTrees.forEach(r => {
  const updatedRecord = r.set('hidden', hidden);


So it reduces the overhead of end-user iterating over all newly added trees. The following is the way to write form conditions for add-more controls.