• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit Search
0

Fillable Field History Tracker?

Community Beginner ,
Nov 16, 2022 Nov 16, 2022

Copy link to clipboard

Copied

I have a document containing a combination of several hundred checkboxes and text fields. Is it possible to create a live list of field names within the PDF itself that contains information (marked checkboxes or text) along with the date that entry was marked? So, for example, let's say my field names were Checkbox 1, Checkbox 2, Text  Field 1, and Text Field 2, and they're all currently empty. 

If I click on Checkbox 2 and enter text into Text Field 1, I would like the list to show

Today's Date: Checkbox 2, Text Field 1

 

I suspect this may require some JavaScript, but unfortunatley, I don't yet know the language to try and implement something like this (assuming it's possible).

TOPICS
How to , JavaScript , PDF forms

Views

3.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 16, 2022 Nov 16, 2022

Something like this?

Votes

Translate

Translate
Community Expert ,
Nov 16, 2022 Nov 16, 2022

Copy link to clipboard

Copied

Something like this?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 16, 2022 Nov 16, 2022

Copy link to clipboard

Copied

Yes! Something like that would be perfect. I'm trying to make sense of the JavaScript. Would you explain the code?

PS: I've read several of your answers (some dating back several years) the past several weeks as I've been learning fillable forms 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 16, 2022 Nov 16, 2022

Copy link to clipboard

Copied

I used the Calculate event of the "Tracker" text field because it executes each time the value of any field is changed. The event.source property is the field that triggers that action, so I used that to get the field's name and then add it to the list. Notice that each time you change a field's value it will add a new line, though. It should be possible to prevent that from happening if that field was already changed that day, but that would require a more complex script. This was more of a POC on how it can be done.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 16, 2022 Nov 16, 2022

Copy link to clipboard

Copied

Thanks, that's very helpful! This is so cool to see it work---I've ported the Javascript over to my other file, and it's also working great.

 

If I uncheck a checkbox or remove the text from a field, is that something that can be easily undone without tracking that event?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 17, 2022 Nov 17, 2022

Copy link to clipboard

Copied

It has nothing to do with it, really. The code doesn't control the events, it just tracks them.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 17, 2022 Nov 17, 2022

Copy link to clipboard

Copied

Ahhh, this is making more sense now. Thanks for the assistance! With that information and some self-study, I've been able to

1. only print the date once if the date already appears

2. put the 'event' entries in a comma separated list

3. remove entries upon unmarking a checkbox.

I, however, had to use a global object and am now running into a security issue. I used the global object to hold the string data so I could check it for the date and whether an entry name has appeared. Is there a different approach where I don't have to rely on a global object and still achieve the above?

 

I'm also running into an issue with the text field always logging an entry, but I think I can eventually resolve that by inputting some conditional check on the text field content.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 17, 2022 Nov 17, 2022

Copy link to clipboard

Copied

Well done!

Regarding your issues:

- I don't see a need for a global variable to do it. Can you share your code? What happens if you change that global variable to a local one?

- When should the text field not log an entry? When the user clears it?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 17, 2022 Nov 17, 2022

Copy link to clipboard

Copied

I've attached the file. I thought I needed a global variable, since that's how I got my mind to make sense of storing the information about what was previously accessed 😄

 

If I place the variable inside the calculation script, then it keeps appending new entries. I only want the checkbox field name to appear if there's a mark in the checkbox. If the checkmark gets removed, then I want the field name to get removed. That's currently working using the global variable, but if it's possible without it, then I think I prefer that.

 

For the text field, the idea is similar. If there's text in the field, I want to track that the field contains text. If more text gets added or partially removed, I don't want to track another instance. If the field is emptied, then I want to remove the tracked entry. Currently, the code is adding an instance when there's text in the field, and then removing the instance when text gets (partially) added or deleted.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 17, 2022 Nov 17, 2022

Copy link to clipboard

Copied

Woops, when I said, "If I place the variable inside the calculation script, then it keeps appending new entries," I meant that placing global.track inside the calculation script will keep overriding the previous.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 17, 2022 Nov 17, 2022

Copy link to clipboard

Copied

I changed it so it uses a local (doc-level) variable instead of a global one. I think the code is not yet perfect, but it gives you a starting point...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 17, 2022 Nov 17, 2022

Copy link to clipboard

Copied

Awesome! It took me some time, but I think I got part of it working 🙂

 

I took your tweak, which was working great; however, it didn't preserve the current string information after saving and closing the document. So, I tried to figure out how to store the data within the PDF. I was reading about storing data within hidden form fields when I realized that I could extract the string data from the Tracker text field! Now, everything preserved even after closing and opening. Really appreciate your guidance; I've learned a lot these past two days.

 

Just need to figure out how to only have the information tracked when text fields are non-empty, and I'll be set. Back to reading for me, haha.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 17, 2022 Nov 17, 2022

Copy link to clipboard

Copied

LATEST

You can add a condition to check if the field's new value is not the same as its default value, and only then add it to the string, like this:

if (event.source.value!=event.source.defaultValue) ...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines