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)
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)
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.pfGetJWTTokenreturns a new token each time it is called, not a cached one that may have expired.
window.pfFormsEngine is undefined
Error message (sample)
Symptoms
- Attempts to access
window.pfFormsEngine.v1throw 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.pfFormsEngineor 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
- See Parent App Integration for the full integration guide.
- See Authentication and Token Errors for related token issues.