Separate/filter forms based on unique value

Avatar

Avatar

meem23

Avatar

meem23

meem23

14-01-2020

I have form created in Adobe LiveCycle Designer and has imported xml from an Access table.  The xml populates 4 fields and the form repeats for every data item. There are 780 output forms. One of the fields is called “owner”.  Out of the 780 forms there are 58 unique owners.  Is there a way to separate/filter the forms based on the unique owner?  So if owner “A” has 50 forms, I want the form to repeat only 50 times. I don’t want to create 58 separate tables in Access if I don’t have to.

Accepted Solutions (0)

Answers (9)

Answers (9)

Avatar

Avatar

meem23

Avatar

meem23

meem23

23-01-2020

It now works to filter - thanks 😀 . But, 2 problems.  When I Save As it doesn't keep the data, the fields are blank; and the dropdown is still visible.  

Avatar

Avatar

radzmar

MVP

Total Posts

2.6K

Likes

386

Correct Answer

485

Avatar

radzmar

MVP

Total Posts

2.6K

Likes

386

Correct Answer

485
radzmar
MVP

23-01-2020

Ok, I had a view into your form. 
There are just a few things to change, to make it finally work. 

 

  1. Change the binding of the page "Main" into !data.dataroot.formInfo[*].

  2. Set the binding of the nested subforms "Logo", "formInfo" and "other" to None.

  3. Remove the script in the layout:ready event of the field "owner".

  4. Change the exit:event into of the drop down into:

 

var cSelection = this.rawValue,
	oSubforms = form1.resolveNodes('Main[*]'), 
	oNode, i;

for (i = 0; i < oSubforms.length; i += 1) {
	oNode = oSubforms.item(i);
	oNode.presence = oNode.formInfo.owner.rawValue === cSelection ? "visible" : "hidden";
}​

 

😉

Avatar

Avatar

radzmar

MVP

Total Posts

2.6K

Likes

386

Correct Answer

485

Avatar

radzmar

MVP

Total Posts

2.6K

Likes

386

Correct Answer

485
radzmar
MVP

22-01-2020

It should work. I build a new form ans XML file by your screenshots and got it work. If you can share your form, I can have a look on it. 

Avatar

Avatar

meem23

Avatar

meem23

meem23

22-01-2020

Hi, I've been trying to get this work and I can't.  Nothing happened when I entered the dropdown and when I exited the dropdown it hid the formsInfo subform's first instance and nothing else. I tried adding a data connection and now the exit event script is working - adds the owners to the dropdown, but I can't get the Main subform to be hidden/visible when selecting an owner from the dropdown. 

Avatar

Avatar

radzmar

MVP

Total Posts

2.6K

Likes

386

Correct Answer

485

Avatar

radzmar

MVP

Total Posts

2.6K

Likes

386

Correct Answer

485
radzmar
MVP

16-01-2020

Ok, a quick solution is to hide or show the subforms depending on the selected owner. 

All you need is a dropdown field in your form with two JavaScripts.

 

The first script is for the enter event. It loads the owners into the dropdown list.

var oDDL = this,
	oDataNodes = xfa.data.dataroot.resolveNodes('formInfo[*]'),
	i, vOwner,
	aOwner = [],
	isExisting = function (oArray, cValue) {
	  return oArray.some(function(oArrayValue) {
	    return cValue === oArrayValue;
	  });
	};
oDDL.clearItems();
// check the owners in all data nodes
for (i = 0; i < oDataNodes.length; i += 1) {
	vOwner = oDataNodes.item(i).owner.value;
	// add a newly found owner to the dropdown list
	if (isExisting(aOwner, vOwner) === false) {
		aOwner.push(vOwner);
		oDDL.addItem(vOwner);
	}
}
// open the dropdown list
xfa.host.openList(oDDL.somExpression);

 

The second script works in the exit event. It controls which subfom is visible or not. 

var cSelection = this.rawValue,
	oSubforms = form1.Main.resolveNodes('formInfo[*]'), 
	oNode, i;

for (i = 0; i < oSubforms.length; i += 1) {
	oNode = oSubforms.item(i);
	oNode.presence = oNode.owner.rawValue === cSelection ? "visible" : "hidden";
}

 

Hope this help!

Avatar

Avatar

meem23

Avatar

meem23

meem23

16-01-2020

Good question.  I’m not well-versed on this subject or scripting, so I don’t know what is possible. Currently I’m using Adobe Acrobat and importing the XML to create the 780 forms.  There is no data connection.  I’m not opposed to having a data connection.  I tried this approach and was not successful.

 

Is this possible:

 

  1. Dropdown that list the owners (A, B, C, etc. – not multiple times: A, A, A, A…..B, B, B….)
  2. Using Adobe Acrobat, import the data – 780 forms are created
  3. Select owner “A” from dropdown
  4. Filtered from 780 to 50
  5. Save As Owner A Forms.pdf
  6. Select owner “B” from dropdown
  7. Filtered 25 forms
  8. Save As Owner B Forms.pdf
  9. Select owner "C"....

Dropdown will need to be hidden after Save As.  The forms will be emailed to the owner and there are questions for them to answer and return back to me.

Avatar

Avatar

radzmar

MVP

Total Posts

2.6K

Likes

386

Correct Answer

485

Avatar

radzmar

MVP

Total Posts

2.6K

Likes

386

Correct Answer

485
radzmar
MVP

15-01-2020

Ok, the XML and form is quite simple. But, how or when do you want to filter the data? There are couple of ways to do filtering but some only work with hardcoded filters like this one. So, what workflow do you have in mind to filter the forms for owner "A" for example?

Avatar

Avatar

meem23

Avatar

meem23

meem23

15-01-2020

Thanks for responding.  Here are screenshots.

Hierarchy:

meem23_1-1579096006945.png

The Main subform repeats for each data item.

XML:

meem23_2-1579096356370.png

 

 

Avatar

Avatar

radzmar

MVP

Total Posts

2.6K

Likes

386

Correct Answer

485

Avatar

radzmar

MVP

Total Posts

2.6K

Likes

386

Correct Answer

485
radzmar
MVP

14-01-2020

To answer this, we'll need more details: Can you please provide an example of the data you're importing into your form and also some screenshots of your forms hierarchy in Designer?