Skip to content

Commit d9e5a32

Browse files
authored
some suggestions
1 parent 8fdb8ac commit d9e5a32

1 file changed

Lines changed: 28 additions & 29 deletions

File tree

support/dynamics-365/field-service/scheduling/missing-form-context-bookable-resource.md

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,73 +4,72 @@ description: Address issues with customized forms based on the default bookable
44
author: m-hartmann
55
ms.author: mhart
66
ms.reviewer: mhart
7-
ms.date: 03/17/2025
7+
ms.date: 03/31/2025
88
ms.custom: sap:Schedule Board
99
---
10-
1110
# Missing form context for internal handlers on customized bookable resource forms
1211

1312
This article helps resolve issues caused by missing form context for internal handlers on the bookable resource form in Microsoft Dynamics 365 Field Service.
1413

1514
## Symptoms
1615

17-
When opening the form to create a bookable resource, the error message **Cannot read properties of undefined (reading 'getFormContext')** appears when selecting a user from the field.
16+
When you select a user from the field on the form while [creating a bookable resource](/dynamics365/field-service/set-up-bookable-resources) in Dynamics 365 Field Service, you might receive the following error message:
1817

19-
## Cause
18+
> Cannot read properties of undefined (reading 'getFormContext')
2019
21-
The system uses a customized form that is based on an old version of the bookable resource form. There was a change in the internal handlers for *onchange* events. They require the execution context to be passed in from the form.
20+
## Cause
2221

23-
## Resolutions
22+
The issue occurs because the system uses a customized form based on an outdated version of the bookable resource form. A change in the internal handlers for `onchange` events now requires the execution context to be passed in from the form.
2423

25-
You can address such issues through Power Apps, by editing the form definitions of the customized forms in the corresponding customizations.xml file, or by running a script in the browser console to update the *onchange* event. You need the System Customizer permission to make the changes outlined below.
24+
## Resolution
2625

2726
> [!IMPORTANT]
28-
> The following resolutions assume that the script error references the function *Mscrm.userid_onchange*. If the error shows on other fields and references other functions such as *Mscrm.accountid_onchange* or *Mscrm.contactid_onchange*, adapt the resolution steps to these functions.
27+
> The following resolutions assume that the script error references the `Mscrm.userid_onchange` function. If the error refers to other fields or functions, such as `Mscrm.accountid_onchange` or `Mscrm.contactid_onchange`, adapt the steps accordingly.
2928
30-
### Update the form in Power Apps
29+
### Resolution 1: Update the form in Power Apps
3130

3231
1. Sign in to Power Apps and open the solution that contains the form.
3332

34-
1. Select the user field and go to the events.
33+
1. Select the **User** field and go to the event settings.
34+
35+
1. Look for the `Mscrm.userid_onchange` event handler.
3536

36-
1. Look for the *Mscrm.userid_onchange* event handler.
37+
If the handler doesn't exist:
3738

38-
If the handler doesn't exist:
39-
4039
1. Add a new event of type **On Change**
4140
1. Select the **Scheduling/BookableResource/BookableResource_main_system_library.js** library.
42-
1. Enter **Mscrm.userid_onchange** in the **Function** field.
43-
1. Ensure the checkboxes **Enabled** and **Pass execution context as first parameter** are active.
41+
1. Enter _Mscrm.userid_onchange_ in the **Function** field.
42+
1. Ensure the **Enabled** and **Pass execution context as first parameter** checkboxes are selected.
4443

45-
If the handler exists:
44+
If the handler exists:
4645

47-
1. Edit the handler and ensure the checkboxe **Pass execution context as first parameter** is active.
46+
1. Edit the handler and ensure the **Pass execution context as first parameter** checkbox is selected.
4847

49-
1. Save and publish the updated form.
48+
1. Save and publish the updated form.
5049

51-
### Validate the customizations.xml file
50+
### Resolution 2: Validate the customizations.xml file
5251

53-
1. Open the customizations.xml file from the solution with the customized form that shows the error in an editor.
52+
1. Open the **customizations.xml** file from the solution associated with the customized form that shows the error in an editor.
5453

55-
1. In the *Handler* element of the *Mscrm.userid_onchange* function, ensure that the *passExecutionContext* attribute is set to **true**.
54+
1. In the `Handler` element of the `Mscrm.userid_onchange` function, ensure the `passExecutionContext` attribute is set to **true**.
5655

57-
1. If changes were made, republish the solution.
56+
1. Republish the solution.
5857

59-
### Run a script in the browser console
58+
### Resolution 3: Run a script in the browser console
6059

6160
To ensure this script has the permission to find and update the required information, you need to run it in a browser tab that has an active session with your enviornment. Additionally, your user account needs the permisssions to update the XML of the customized bookable resource form.
6261

63-
1. Open the environment in your browser. The following steps describe how to run the script in Microsoft Edge.
62+
1. Open the environment in your browser. The following instructions use Microsoft Edge as an example.
6463

65-
1. Open **DevTools** by pressing F12 or by selecting the ellipsis (…) > **More tools** > **Developer tools**
64+
1. Open **DevTools** by pressing F12 or navigating to ellipsis (…) > **More tools** > **Developer tools**
6665

67-
1. In **DevTools**, select the **Console** tab and select **Clear Console**.
66+
1. Select the **Console** tab in the DevTools and select **Clear Console**.
6867

69-
1. Copy and paste the code below into the console window.
68+
1. Copy and paste the following JavaScript code into the console.
7069

71-
1. Update the ORG constant to the URL for the environment.
70+
1. Update the `ORG` constant in the script with your environment URL, for example, `contoso.crm.dynamics.com`.
7271

73-
1. Run the code and review the script output.
72+
1. Run the script and review the output to confirm the updates.
7473

7574
```JavaScript
7675
const ORG = "<YOUR-ENVIRONMENT-URL>"; // for example "contoso.crm.dynamics.com"

0 commit comments

Comments
 (0)