React Web - Deleted fields are returns from field manager

Hi,

According to the documentation, if I want to be able to access the document fields I should do it by using the field manager as such:

    const { Core } = viewerInstance;
    const { annotationManager } = Core;
    const fieldManager = annotationManager.getFieldManager();
    const documentFields = fieldManager.getFields();

For some reason, when I’m removing a field ( using the “Forms” tool) and trying to access the list of fields again the getFields return all the fields even those that were deleted.
Not sure if this is a bug or there are other ways ( tried to use set up an event listener by following the steps from PDFTron but it triggers when moving between tools view → forms).

Hopefully, you could help me :pray:

WebViewer Version: 8.3.0
Do you have an issue with a specific file(s)? - Every file
Are you using the WebViewer server? - No
Is your issue related to a front-end framework? - React

I’m attaching a link for a screen recording ScreenRecording.mov - Google Drive ( please let me know if you have difficulties opening it)

Best regards :slight_smile:

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Hi Sefi,

This is currently the expected behaviour. The form builder will only delete the widget but not the underlying field. The field is considered deleted as well because you can no longer interact with it.

What is your use case for needing the field to be deleted entirely? Perhaps I can help with an alternative.

Best Regards,
Ahmad Moaaz
Software Developer
PDFTron Systems, Inc.
www.pdftron.com

Hi Ahmad,

Thank you for replying, I want to be able to save and manage the fields on my database in order to, later on, have a business logic such as setting “auto-fill fields” and create a copy of the document on the following cases:

  1. A field has been added.
  2. A field has been deleted ( the case I was relating to).
  3. A field has been changed: name/ default value/ flags.

Hi Sefi,

For checking whether the field is deleted, in your case, you could get the associated widgets on the field, and if there are none, it can be ignored/considered deleted.

You can get the widgets using the field.widgets property on a field like so:

const { Core } = viewerInstance;
const { annotationManager } = Core;
const fieldManager = annotationManager.getFieldManager();
const documentFields = fieldManager.getFields();
documentFields.filter(field => field.widgets.length > 0); // Filter out fields that have no widgets (deleted)

Let me know if this doesn’t work for you or if there are any issues.

Best Regards,
Ahmad Moaaz
Software Developer
PDFTron Systems, Inc.
www.pdftron.com

Worked perfectly, thanks a lot :slight_smile: :pray: