You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: support/dynamics-365/field-service/scheduling/missing-form-context-bookable-resource.md
+28-29Lines changed: 28 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,73 +4,72 @@ description: Address issues with customized forms based on the default bookable
4
4
author: m-hartmann
5
5
ms.author: mhart
6
6
ms.reviewer: mhart
7
-
ms.date: 03/17/2025
7
+
ms.date: 03/31/2025
8
8
ms.custom: sap:Schedule Board
9
9
---
10
-
11
10
# Missing form context for internal handlers on customized bookable resource forms
12
11
13
12
This article helps resolve issues caused by missing form context for internal handlers on the bookable resource form in Microsoft Dynamics 365 Field Service.
14
13
15
14
## Symptoms
16
15
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:
18
17
19
-
## Cause
18
+
> Cannot read properties of undefined (reading 'getFormContext')
20
19
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
22
21
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.
24
23
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
26
25
27
26
> [!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.
29
28
30
-
### Update the form in Power Apps
29
+
### Resolution 1: Update the form in Power Apps
31
30
32
31
1. Sign in to Power Apps and open the solution that contains the form.
33
32
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.
35
36
36
-
1. Look for the *Mscrm.userid_onchange* event handler.
37
+
If the handler doesn't exist:
37
38
38
-
If the handler doesn't exist:
39
-
40
39
1. Add a new event of type **On Change**
41
40
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.
44
43
45
-
If the handler exists:
44
+
If the handler exists:
46
45
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.
48
47
49
-
1. Save and publish the updated form.
48
+
1. Save and publish the updated form.
50
49
51
-
### Validate the customizations.xml file
50
+
### Resolution 2: Validate the customizations.xml file
52
51
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.
54
53
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**.
56
55
57
-
1.If changes were made, republish the solution.
56
+
1.Republish the solution.
58
57
59
-
### Run a script in the browser console
58
+
### Resolution 3: Run a script in the browser console
60
59
61
60
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.
62
61
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.
64
63
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**
66
65
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**.
68
67
69
-
1. Copy and paste the code below into the console window.
68
+
1. Copy and paste the following JavaScript code into the console.
70
69
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`.
72
71
73
-
1. Run the code and review the script output.
72
+
1. Run the script and review the output to confirm the updates.
74
73
75
74
```JavaScript
76
75
constORG="<YOUR-ENVIRONMENT-URL>"; // for example "contoso.crm.dynamics.com"
0 commit comments