Skip to content

Embedded Content Troubleshooting

This article covers common issues when injecting custom HTML into ProcessFactorial Forms using window.pfFormsEngine.v1.


pfFormsEngine.v1 not found on window

Error message (sample)

pfFormsEngine.v1 not found on window

Symptoms

  • The JavaScript console shows this error when your script attempts to access window.pfFormsEngine.v1.
  • Injected HTML does not appear and setValue/getValue calls fail.

Root cause

The ProcessFactorial Forms scripts have not finished loading, or the form snippet is not embedded on the current page.

Resolution

  • Verify the form snippet <script> tag is present and loading correctly (check the Network tab for 404s or errors).
  • If your code runs before the form scripts load, wait for the form to initialize by calling await window.pfFormsEngine.v1.whenReady(15000) instead of accessing .v1 directly.
  • Poll for window.pfFormsEngine with a retry loop if you must run code before the form is guaranteed to be ready.

whenReady(...) returns false

Error message (sample)

Form not ready (contentLoaded not seen)

Symptoms

  • The Promise returned by whenReady(15000) resolves to false.
  • Injected content or API calls that depend on the form being ready do not work.

Root cause

The form did not complete initialization within the specified timeout. This can happen if:

  • An error occurred during form loading (check the console and Network tab).
  • The timeout value is too short for the form's complexity or network conditions.
  • The form snippet's data-base-url or token is invalid, preventing the form from loading.

Resolution

  • Increase the timeout value — complex forms with many pages or reference data may need longer than the default 10 seconds.
  • Check the browser console for other errors during form initialization.
  • Verify the form snippet data-base-url and token are correct (re-export from the configuration portal if needed).

InjectHTML fails with "Field wrapper not found"

Error message (sample)

{ "injected": false, "reason": "Field wrapper not found", "fieldId": "10000000-..." }

Symptoms

  • InjectHTML returns an object with injected: false instead of an HTMLElement.
  • The target field area remains empty or shows the original placeholder.

Root cause

The fieldId passed to InjectHTML does not correspond to an existing field on the current page, or the field is inside a repeating/grouped section and the required groupCode/groupIndex parameters were omitted.

Resolution

  • Verify you are using the correct placeholder fieldId. The field ID can be found in the form designer or by inspecting the DOM for the data-fieldid attribute on the target element.
  • If the field exists inside a repeating section (grid/group), you must also pass the groupCode and groupIndex parameters:
api.InjectHTML(fieldId, htmlContent, groupCode, groupIndex);
  • Ensure the target field is rendered on the currently visible page — fields on hidden tabs or pages are not in the DOM and cannot be found.

setValueByQuery returns "No matching reference data found"

Error message (sample)

{ "handled": false, "error": "No matching reference data found" }

Symptoms

  • setValueByQuery does not set the lookup field value.
  • The returned object has handled: false.

Root cause

One of the following:

  1. The target field is not on the currently visible page — reference data is lazy-loaded per page.
  2. The target field is a typeahead/autocomplete field, not a <select> dropdown.
  3. The filter attribute (e.g. productnumber) is not in the Additional Display Attributes of the lookup configuration, so it's not available in the reference data API response.
  4. No record matches the provided query.

Resolution

  • Ensure the target field is on the currently visible page before calling setValueByQuery.
  • Check that the field is a standard <select> dropdown (not a typeahead).
  • Verify the filter attribute is included in the lookup's Additional Display Attributes in the configuration portal.
  • If the query is correct but no match is found, the record may not exist in the reference data — use setValue with a known key value instead.

Notes and references