Skip to content

Parent App Integration Troubleshooting

This article covers common issues when integrating ProcessFactorial Forms into a parent application, including token problems and missing API surface.


Authenticated forms require the parent web app to expose window.pfGetJWTToken

Error message (sample)

Authenticated forms require the parent web app to expose window.pfGetJWTToken

Symptoms

  • A red alert banner is shown and the form does not render.
  • A JavaScript error with this message appears in the browser console.

Root cause

The form requires authentication but the parent application has not defined window.pfGetJWTToken. The Form Engine calls this function every time it needs a JWT token to authorise API requests.

Resolution

Define window.pfGetJWTToken as an async function that returns a valid JWT token string. For example, with MSAL:

window.pfGetJWTToken = async () => {
    const response = await instance.acquireTokenSilent({
        scopes: ['api://your-app-registration/access_as_user'],
        account: accounts[0]
    });
    return response.accessToken;
};

See Parent App Integration for the full contract and examples.


Form loads but API calls fail with 401

Error message (sample)

Record does not exist or you do not have access to it

Symptoms

  • A red alert banner with this message appears.
  • The form may render partially but cannot load or save data.
  • Network tab shows HTTP 401 responses to PF Forms API calls.

Root cause

The JWT token returned by window.pfGetJWTToken is expired, invalid, or has the wrong audience or scopes.

Resolution

  • Verify the token is being acquired successfully (check your auth provider's token acquisition).
  • Ensure the token's audience and scopes match what the PF Forms API expects.
  • Check that the token has not expired — tokens typically have a short lifetime and may need refreshing.
  • Ensure window.pfGetJWTToken returns a new token each time it is called, not a cached one that may have expired.

window.pfFormsEngine is undefined

Error message (sample)

Cannot read properties of undefined (reading 'v1')

Symptoms

  • Attempts to access window.pfFormsEngine.v1 throw an error.
  • The form may be visible but you cannot call the Forms Engine API.

Root cause

The Forms Engine API is only available after the form snippet has loaded and initialized. If your code runs before the snippet, the global object is not yet defined.

Resolution

  • Poll for window.pfFormsEngine or use a callback approach to ensure the snippet has loaded.
  • Call await window.pfFormsEngine.v1.whenReady(15000) before making API calls.
  • Consider placing your integration script after the form snippet in the page HTML.

Notes and references