Page 1 of 2

If there are no entries in the subform - to hide the subform

Posted: Fri May 22, 2020 4:15 pm
by kknm
If there are no entries in the subform - how to hide the subform ?

Re: If there are no entries in the subform - to hide the sub

Posted: Fri May 22, 2020 4:25 pm
by kev1n

Code: Select all

var subformId = 'accform'; // <--- replace with your subform object ID
if (nuSubformObject(subformId).rows.length < 2) {
  nuHide(subformId);
}

Re: If there are no entries in the subform - to hide the sub

Posted: Sun May 24, 2020 2:56 am
by kev1n
Please let me know if the code works for you.

Re: If there are no entries in the subform - to hide the sub

Posted: Thu Oct 01, 2020 8:05 am
by kknm
kev1n wrote:Please let me know if the code works for you.
Thanks, it works for me.
How would I apply this to all subforms on the main form at once without specifying the ID of each form?

Re: If there are no entries in the subform - to hide the sub

Posted: Fri Oct 02, 2020 9:13 am
by kev1n
Call this function hideEmptySubforms() to hide all empty subforms

Code: Select all

function hideEmptySubforms() {
	nuSERVERRESPONSE.objects.map(item => {
	 
		if (item.type == 'subform') {
			if (nuSubformObject(item.id).rows.length == 1) {
				nuHide(item.id);
			}

		}
		
	})
}

Re: If there are no entries in the subform - to hide the sub

Posted: Mon Oct 05, 2020 9:40 am
by kknm
kev1n wrote:Call this function hideEmptySubforms() to hide all empty subforms

Code: Select all

function hideEmptySubforms() {
	nuSERVERRESPONSE.objects.map(item => {
	 
		if (item.type == 'subform') {
			if (nuSubformObject(item.id).rows.length == 1) {
				nuHide(item.id);
			}

		}
		
	})
}
Unfortunately this doesn't work - nothing happens.

Re: If there are no entries in the subform - to hide the sub

Posted: Mon Oct 05, 2020 9:42 am
by kev1n
How did you call the function and where?

Re: If there are no entries in the subform - to hide the sub

Posted: Mon Oct 05, 2020 10:09 am
by kknm
kev1n wrote:How did you call the function and where?
hideSubForms.png
First I tried it without specifying a function, then I hung it up on the button of the main form through onclick.

Re: If there are no entries in the subform - to hide the sub

Posted: Mon Oct 05, 2020 10:12 am
by kev1n
You need to call the function somewhere

Code: Select all

hideEmptySubforms();

Re: If there are no entries in the subform - to hide the sub

Posted: Mon Oct 05, 2020 10:16 am
by kknm
kev1n wrote:You need to call the function somewhere

Code: Select all

hideEmptySubforms();
pusto.png