Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Sorting Data in a Dynamic Table - Need blank rows forced to the bottom after the sort.

Avatar

Level 6

Hello All,

I have successfully utilized the sort table function within a dynamic table using the John Brinkman Sales Report file. It works beautifully, the magic is in the Variables script. It would be amazing to take this one step further and update the code to always list any blank rows at the bottom of the table no matter if the sort is ascending or descending. John's script does not account for this so if anyone can help me tweak this code to make that happen, I would be eternally grateful. 

My Designer PDF is located at the link below.

https://drive.google.com/drive/folders/1Qhz-DNYM40ECzUGEl2w34egEzhKBaaoV?usp=sharing

Thank you in advance!

 

1 Accepted Solution

Avatar

Correct answer by
Employee

I think I found a solution that works for different field types. If you want numeric input to be sorted numeric then your field must be Number or Decimal - otherwise it will sort as text.

https://documentcloud.adobe.com/link/review?uri=urn:aaid:scds:US:68787b63-a702-4977-b0c6-4968490fdfc...

View solution in original post

15 Replies

Avatar

Employee

Hi,

here is a bit of a hack that seems to do what you want based on the existing logic. Try it out by replacing the sortRoutine in the script object.

... the solution would not work under all circumstances - see my sample in a later post.

 

Avatar

Level 6
Thank you so much! I appreciate your time. I replaced the sortRoutine script and realized when testing that it didn't force the blank rows to the bottom so if you have any ideas on what I can do differently I would love to hear them. Unfortunately using this updated script or my original script is crashing Designer in the HTML preview. Any advice or thoughts on how to make this work in both PDF/XDP and HTML for AEM would be appreciated.

Avatar

Employee
HTML is a whole new ballgame. Are you talking about an AEM Forms application where you render the XDP as HTML5 or Adaptive Forms?

Avatar

Level 6
We are in the phase of building our 2000 forms from Word and Excel into Designer PDFs. Then we will take those and produce XDP files which will then be uploaded to AEM environment for publishing. We will eventually get them into Adaptive but for now, I'm trying to get them into XDP as HTML5 keeping in mind the end goal is Adaptive forms. We are a govt agency so its the path I have to take. Does that help explain my situation?

Avatar

Level 6
I opened the file in Acrobat and it does not keep the blank row at the bottom of the table. I also see that if I use digits that vary in decimal placed they do not go in the proper order, i.e., 10 is a lower number than 3 in the sort. Is the sort working on your system?

Avatar

Employee
The sort is alphabetical, not numerical. What is supposed to be in those fields?

Avatar

Employee
HTML rendering works 90-95% but there are differences which you will have to cater for in your designs. See here https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwiJqa6JibDuA... around page 714 for differences between PDF and HTML

Avatar

Employee
Adaptive Forms are completely new approach. You can use the XDP as the "schema" to place fields and logic (to a degree) in your AFs but you would work on these forms more or less from scratch. You can use some AI service to convert PDF to AF (https://experienceleague.adobe.com/docs/aem-forms-automated-conversion-service/using/introduction.ht...)

Avatar

Level 6
Thank you for all the information with the HMTL! This is helpful. I see now that this sort works alphabetically and it even works on the dates. This is a generic table that i'm working on for my team to use in their forms if the need arises. It could include numbers such as check numbers. Is there a way to cover both basis? This is kind of a template if that makes sense.

Avatar

Employee
My last post as it is late here in Germany. My trick does not work with numbers - only with strings - that is why it did not sort the empty columns for you. I guess that algorithm needs to be changed big time and we somehow need to check the field type. The table fields all seem to be interpreted as text. I have to think about it - we will talk next week.

Avatar

Level 6
Thank you again for your time. Have a nice weekend!

Avatar

Correct answer by
Employee

I think I found a solution that works for different field types. If you want numeric input to be sorted numeric then your field must be Number or Decimal - otherwise it will sort as text.

https://documentcloud.adobe.com/link/review?uri=urn:aaid:scds:US:68787b63-a702-4977-b0c6-4968490fdfc...

Avatar

Level 6
Thank you so much for your help! This worked perfectly!