Skip to content

Commit 406a19d

Browse files
authored
Merge pull request #8662 from MicrosoftDocs/main
Auto push to live 2025-04-08 02:00:02
2 parents 36b6c3c + e001951 commit 406a19d

File tree

18 files changed

+583
-147
lines changed

18 files changed

+583
-147
lines changed

.openpublishing.redirection.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13267,6 +13267,10 @@
1326713267
{
1326813268
"source_path": "support/dynamics-365/sales/the-record-could-not-be-deleted.md",
1326913269
"redirect_url": "/troubleshoot/power-platform/dataverse/working-with-solutions/the-record-could-not-be-deleted"
13270+
},
13271+
{
13272+
"source_path": "support/power-platform/power-automate/dataverse-cds/cds-user-cannot-access-power-automate-business-process-flows-on-demand-workflows.md",
13273+
"redirect_url": "/previous-versions/troubleshoot/power-platform/power-automate/cloud-flows/cds-user-cannot-access-power-automate-business-process-flows-on-demand-workflows"
1327013274
}
1327113275
]
1327213276
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: Windows VM startup is stuck on "Applying Group Policy Environment policy" in Microsoft Azure
3+
description: Provides troubleshooting steps for an Azure virtual machine (VM) that is stuck in startup with message, "Applying Group Policy Environment policy."
4+
ms.date: 03/03/2025
5+
author: cwhitley-MSFT
6+
ms.author: cwhitley
7+
ms.service: azure-virtual-machines
8+
ms.collection: windows
9+
ms.custom: sap:My VM is not booting
10+
---
11+
12+
# VM startup is stuck on "Applying Group Policy Environment policy"
13+
14+
**Applies to:** :heavy_check_mark: Windows VMs
15+
16+
This article discusses an issue that causes a Microsoft Azure virtual machine (VM) to get stuck during startup on the **Applying Group Policy Environment policy** screen.
17+
18+
## Symptoms
19+
20+
A Windows VM doesn't start. When you use [Boot diagnostics](./boot-diagnostics.md) to view the screenshot of the VM, you see that the Windows operating system displays the message, **Applying Group Policy Environment policy**.
21+
22+
:::image type="content" source="media/applying-group-policy-environment-policy/ApplyingGroupPolicyEnvironmentPolicy.png" alt-text="Screenshot of Windows operating system displaying the message, 'Applying Group Policy Environment policy'.":::
23+
## Cause
24+
25+
Further investigation is required to determine the specific cause of this issue.
26+
27+
## Collect memory dump for troubleshooting
28+
29+
For this scenario, Azure Support requires a memory dump in order to be able to troubleshoot and diagnose the issue.
30+
31+
Follow the steps in [this article](./collect-os-memory-dump-file.md) to collect a memory dump. Then, [create a support request](https://ms.portal.azure.com/#blade/Microsoft_Azure_Support/HelpAndSupportBlade/overview?DMC=troubleshoot).
32+
33+
[!INCLUDE [Azure Help Support](../../../includes/azure-help-support.md)]
18.1 KB
Loading

support/azure/virtual-machines/windows/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@
312312
href: boot-error-0xc0000221.md
313313
- name: Boot failure with error INACCESSIBLE_BOOT_DEVICE
314314
href: windows-boot-failure.md
315+
- name: Azure VM login hangs at "Applying Group Policy Environment"
316+
href: applying-group-policy-environment-policy.md
315317
- name: Troubleshoot Windows VM OS with missing boot manager
316318
href: os-bootmgr-missing.md
317319
- name: OS isn't found
Lines changed: 290 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,290 @@
1+
---
2+
title: Missing Form Context for Internal Handlers on Customized Bookable Resource Forms
3+
description: Addresses issues with customized forms that are based on the default bookable resource form for Dynamics 365 Field Service.
4+
author: m-hartmann
5+
ms.author: mhart
6+
ms.reviewer: mhart
7+
ms.date: 04/08/2025
8+
ms.custom: sap:Schedule Board
9+
---
10+
# Form context for internal handlers is missing on customized bookable resource forms
11+
12+
This article helps resolve an issue caused by missing form context for internal handlers on bookable resource forms in Microsoft Dynamics 365 Field Service.
13+
14+
## Symptoms
15+
16+
While [creating a bookable resource](/dynamics365/field-service/set-up-bookable-resources) in Dynamics 365 Field Service, you might receive the following error message when you select a user from a field on the form:
17+
18+
> Cannot read properties of undefined (reading 'getFormContext')
19+
20+
## Cause
21+
22+
The issue occurs because the system uses a customized form that is based on an outdated version of the bookable resource form. A change to the internal handlers for `onchange` events now requires the execution context to be passed in from the form.
23+
24+
## Resolution
25+
26+
Use one of the listed resolutions to ensure that the execution context is passed as the first parameter.
27+
28+
> [!IMPORTANT]
29+
> 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`, adjust the steps accordingly.
30+
31+
### Resolution 1: Update the form in Power Apps
32+
33+
1. Sign in to Power Apps and open the solution that contains the form.
34+
35+
1. Select the **User** field and go to the event settings.
36+
37+
1. Look for the `Mscrm.userid_onchange` event handler.
38+
39+
If the handler doesn't exist:
40+
41+
1. Add a new event of type **On Change**.
42+
1. Select the **Scheduling/BookableResource/BookableResource_main_system_library.js** library.
43+
1. Enter **Mscrm.userid_onchange** in the **Function** field.
44+
1. Ensure the **Enabled** and **Pass execution context as first parameter** checkboxes are selected.
45+
46+
If the handler exists:
47+
48+
1. Edit the handler and ensure the **Pass execution context as first parameter** checkbox is selected.
49+
50+
1. Save and publish the updated form.
51+
52+
### Resolution 2: Validate the customizations.xml file
53+
54+
1. Open the **customizations.xml** file from the solution associated with the customized form that shows the error in an editor.
55+
56+
1. In the `Handler` element of the `Mscrm.userid_onchange` function, ensure the `passExecutionContext` attribute is set to **true**.
57+
58+
1. Republish the solution.
59+
60+
### Resolution 3: Run a script in the browser console
61+
62+
To ensure this script has permission to find and update the required information, you need to run it in a browser tab that has an active session with your environment. Additionally, your user account needs permisssion to update the XML of the customized bookable resource form.
63+
64+
1. Open the environment in your browser. The following instructions use Microsoft Edge as an example.
65+
66+
1. Open **DevTools** by pressing <kbd>F12</kbd> or navigating to ellipsis (&hellip;) > **More tools** > **Developer tools**.
67+
68+
1. Select the **Console** tab in DevTools and select **Clear Console**.
69+
70+
1. Copy and paste the following JavaScript code into the console.
71+
72+
```JavaScript
73+
const ORG = "<YOUR-ENVIRONMENT-URL>"; // for example "contoso.crm.dynamics.com"
74+
75+
async function fixBookableResourceForms() {
76+
77+
console.log("Starting Bookable Resource Form fetch process...");
78+
79+
let publishXML = false;
80+
81+
try {
82+
83+
const response = await fetch(`https://${ORG}/api/data/v9.2/systemforms?$filter=objecttypecode eq 'bookableresource'`);
84+
85+
if (!response.ok) {
86+
87+
throw new Error(`Error fetching resources: ${response.statusText}`);
88+
89+
}
90+
91+
const data = await response.json();
92+
93+
const forms = data.value;
94+
95+
if(forms.length !== 0) {
96+
97+
for (const form of forms) {
98+
99+
console.log(` Checking form ${form.name} (${form.formid})...`);
100+
101+
const formXML = form.formxml;
102+
103+
const parser = new DOMParser();
104+
105+
const xmlDoc = parser.parseFromString(formXML, "text/xml");
106+
107+
const handlers = xmlDoc.getElementsByTagName("Handler");
108+
109+
const userIdHandlers = []
110+
111+
for (let i = 0; i < handlers.length; i++) {
112+
113+
const handler = handlers[i];
114+
115+
if (
116+
117+
handler.getAttribute("functionName") === "Mscrm.userid_onchange" &&
118+
119+
handler.getAttribute("libraryName") === "Scheduling/BookableResource/BookableResource_main_system_library.js"
120+
121+
) {
122+
123+
userIdHandlers.push(handler);
124+
125+
}
126+
127+
}
128+
129+
if (userIdHandlers.length > 1) {
130+
131+
console.warn(`Form ${form.name} (${form.formid}) has more than 1 Mscrm.userid_onchange event handlers (has ${userIdHandlers.length}).`);
132+
133+
}
134+
135+
else if (userIdHandlers.length === 0) {
136+
137+
console.warn(`Form ${form.name} (${form.formid}) has 0 Mscrm.userid_onchange event handlers.`);
138+
139+
continue;
140+
141+
}
142+
143+
await Promise.all(userIdHandlers.map(async handler => {
144+
145+
if (
146+
147+
handler.getAttribute("functionName") === "Mscrm.userid_onchange" &&
148+
149+
handler.getAttribute("libraryName") === "Scheduling/BookableResource/BookableResource_main_system_library.js" &&
150+
151+
handler.getAttribute("passExecutionContext") === "true"
152+
153+
) {
154+
155+
console.log(` Form ${form.name} (${form.formid}) has the correct Mscrm.userid_onchange event handler.`);
156+
157+
}
158+
159+
else if (
160+
161+
handler.getAttribute("functionName") === "Mscrm.userid_onchange" &&
162+
163+
handler.getAttribute("libraryName") === "Scheduling/BookableResource/BookableResource_main_system_library.js" &&
164+
165+
(handler.getAttribute("passExecutionContext") === "false" || handler.getAttribute("passExecutionContext") === null)
166+
167+
) {
168+
169+
console.log(` Form ${form.name} (${form.formid}) has the Mscrm.userid_onchange event handler but the passExecutionContext attribute is not set to true. Setting it to true...`);
170+
171+
handler.setAttribute("passExecutionContext", "true");
172+
173+
const serializer = new XMLSerializer();
174+
175+
const updatedXml = serializer.serializeToString(xmlDoc);
176+
177+
await updateBookableResourceForms(form, updatedXml);
178+
179+
publishXML = true;
180+
181+
}
182+
183+
return Promise.resolve();
184+
185+
}));
186+
187+
}
188+
189+
} else {
190+
191+
console.log("No Bookable Resource forms found. Nothing was done");
192+
193+
}
194+
195+
} catch (error) {
196+
197+
console.error(error.message);
198+
199+
}
200+
201+
if(publishXML) {
202+
203+
console.log("Publishing changes...");
204+
205+
await publishChanges();
206+
207+
publishXML = false;
208+
209+
}
210+
211+
console.log("Finished");
212+
213+
}
214+
215+
async function updateBookableResourceForms(form, formxml) {
216+
217+
console.log(` Updating Bookable Resource Form ${form.name} (${form.formid}) ...`);
218+
219+
try {
220+
221+
const reqBody = JSON.stringify({formxml: formxml});
222+
223+
const updateResponse = await fetch(`https://${ORG}/api/data/v9.2/systemforms(${form.formid})`, {
224+
225+
method: 'PATCH',
226+
227+
headers: {
228+
229+
'Content-Type': 'application/json'
230+
231+
},
232+
233+
body: reqBody
234+
235+
});
236+
237+
if (!updateResponse.ok) {
238+
239+
throw new Error(`Error updating form ${formid}: ${updateResponse.statusText}`);
240+
241+
}
242+
243+
console.log(` Form ${form.name} (${form.formid}) updated successfully.`);
244+
245+
} catch (error) {
246+
247+
console.error(error.message);
248+
249+
}
250+
251+
console.log(` Done updating Bookable Resource Form ${form.name} (${form.formid}).`);
252+
253+
}
254+
255+
async function publishChanges() {
256+
257+
console.log(" Starting publish XML process...");
258+
259+
const publishResponse = await fetch(`https://${ORG}/api/data/v9.2/PublishXml`, {
260+
261+
method: 'POST',
262+
263+
headers: {
264+
265+
'Content-Type': 'application/json'
266+
267+
},
268+
269+
body: '{"ParameterXml": "<importexportxml><entities><entity>bookableresource</entity></entities></importexportxml>"}'
270+
271+
});
272+
273+
if (!publishResponse.ok) {
274+
275+
throw new Error(`Error publishing XML: ${publishResponse.statusText}`);
276+
277+
}
278+
279+
console.log(" Done publish XML process.");
280+
281+
}
282+
283+
// Call the function
284+
285+
fixBookableResourceForms()
286+
```
287+
288+
1. Update the `ORG` constant in the script with your environment URL, for example, `contoso.crm.dynamics.com`.
289+
290+
1. Run the script and review the output to confirm the updates.

support/dynamics-365/field-service/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,6 @@
8484
items:
8585
- name: Issue with cascading crew changes when assigning a booking
8686
href: scheduling/cascade-crew-changes-booking.md
87+
- name: Form context is missing on bookable resource forms
88+
href: scheduling/missing-form-context-bookable-resource.md
8789

support/dynamics-365/field-service/welcome-field-service.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ landingContent:
105105
links:
106106
- text: Issue with cascading crew changes when assigning a booking
107107
url: scheduling/cascade-crew-changes-booking.md
108+
- text: Missing form context on bookable resource forms
109+
url: scheduling/missing-form-context-bookable-resource.md
108110

109111
# Card
110112
- title: Integrations

0 commit comments

Comments
 (0)