web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

How to pass Execution Context to JavaScript function called from HTML resource?

(0) ShareShare
ReportReport
Posted on by 22

Hello all,

Xrm.Page is being deprecated and Microsoft has announced that:

"Although Xrm.Page is deprecated, parent.Xrm.Page will continue to work in case of HTML web resources embedded in forms as this is the only way to access the form context from the HTML web resource.


It is not clear to me what happens when you have HTML resources, which call JS functions. How can I pass the Execution Context in those functions, when I do not have the context in the HTML file?



Example:

<!DOCTYPE html>
<html>
<head>
<title>Transactions</title>
<meta charset="utf-8" />

<script src="">ajax.googleapis.com/.../script>
<script src="">code.jquery.com/.../script>
<script src="ClientGlobalContext.js.aspx" type="text/javascript"></script>
<script type="text/javascript" src="../WebResources/la_datatables.min.js"></script>
<link href="../WebResources/la_datatables.min.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="">ajax.googleapis.com/.../jquery-ui.css" type="text/css" media="all" />
<script type="text/javascript" src="../WebResources/gas_RestHelper.js"></script>

<script>
var headers = [];
var columns = [];
var columnValues = [];
var tableHeaders = [];

$(document).ready(function () {

$('#loading').hide();
try {
var crmForm = window.parent.Alert.getCrmWindow();

if (crmForm) {
crmForm.myLibrary_library.getExampleButtonClick(); //I need the Execution Context to be passed in this function
}

...

Thank you

I have the same question (0)
  • Suggested answer
    PerryDev Profile Picture
    60 on at
    RE: How to pass Execution Context to JavaScript function called from HTML resource?

    Hi Dadele

    I'm working for a project with a custom HTML page in a model driven app and after several research on web I have come to the conclusion that is actually impossible to interact with the Dataverse "directly". The only way was to use window.parent or window.xrm, i don't remember the exactly syntax, but it's been deprecated. Even your ClientGlobalContext.js.aspx seems become useless:

    dynamics-chronicles.com/.../clientglobalcontextjsaspx-deprecated-dynamics-365-how-replace

    So i resolve my issue using the Microsoft web API. in your case you have to handle the button click event in vanilla js and than make an API operation to the dataverse.

    Here some useful documentation:

    docs.microsoft.com/.../overview

    docs.microsoft.com/.../compose-http-requests-handle-errors

    I hope this can help you :)

    In that case consider marking this post as a solution.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 76 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 55 Most Valuable Professional

#3
Anthony Blake Profile Picture

Anthony Blake 43 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans