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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Xrm.page JavaScript update

(0) ShareShare
ReportReport
Posted on by 515

I'm going through our javascript code to remove depreciated JavaScript code and replacing where appropriate.

I have one piece of code which uses  Xrm.Page.data.entity.getId()

However as it's not called from a field change or load event, I'm not sure how to add the Execution Context to this.

Is there a way around this at all?


Thanks

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    How/When is the code being called?  Or can you post your code so we can see it?

    You can always add this to it, then see if its working or not:

    formContext.data.entity.getId();

  • Lee-Martin Profile Picture
    515 on at

    It's part of the ribbon (according to the description)- The problem is I can't see that it's being called from anywhere - I've not worked on the project until I've been asked to do this tidy up

  • Lee-Martin Profile Picture
    515 on at

    Code is

    (function() {

    Develop1_RibbonCommands_runDialogGrid = function(ids, objectTypeCode, dialogId) {

       if ((ids == null) || (!ids.length)) {

           alert(window.LOCID_ACTION_NOITEMSELECTED);

           return;

       }

       if (ids.length > 1) {

           alert(window.LOCID_GRID_TOO_MANY_RECORDS_IWF);

           return;

       }

       var rundialog = Mscrm.CrmUri.create('/cs/dialog/rundialog.aspx');

       rundialog.get_query()['DialogId'] = dialogId;

       rundialog.get_query()['ObjectId'] = ids[0];

       rundialog.get_query()['EntityName'] = objectTypeCode;

       openStdWin(rundialog,buildWinName(null),615,480,null);

    }

    Develop1_RibbonCommands_runDialogForm = function(objectTypeCode, dialogId) {

       var primaryEntityId = Xrm.Page.data.entity.getId();

       var rundialog = Mscrm.CrmUri.create('/cs/dialog/rundialog.aspx');

       rundialog.get_query()['DialogId'] = dialogId;

       rundialog.get_query()['ObjectId'] = primaryEntityId;

       rundialog.get_query()['EntityName'] = objectTypeCode;

       var hostWindow = window;

           if (typeof(openStdWin) == 'undefined') {

               hostWindow = window.parent; // Support for Turbo-forms in CRM2015 Update 1

           }

           if (typeof(hostWindow.openStdWin) != 'undefined') {

               hostWindow.openStdWin(rundialog, hostWindow.buildWinName(null), 615, 480, null);

           }

    }

    })();

  • Suggested answer
    Community Member Profile Picture
    on at

    Oh, custom buttons, ok.  Here are some articles on passing in parameters, youll have to use the ribbon workbench - you can either install in or get to it from the XRMtoolbox.

    community.dynamics.com/.../getting-dynamics-365-formcontext-from-ribbon-workbench

    community.dynamics.com/.../how-to-pass-execution-context-as-a-parameter-in-ribbon-workbench

  • Lee-Martin Profile Picture
    515 on at

    cheers

  • Lee-Martin Profile Picture
    515 on at

    Is there a quick and easy way I can find out what part of the ribbon accesses that JavaScript file?

  • Suggested answer
    Amit Prajapati Profile Picture
    162 on at

    Hi , You can use following code to retrive the Entity Id from the query string parameter which comes from the Global Content:

    var utility = parent.Xrm.Utility; // if using on HTML page

    var utility = Xrm.Utility; // if using on Entity form

    var globalContext = utility.getGlobalContext();

    var queryparameter = globalContext.getQueryStringParameters();

    var recordid= queryparameter.id.replace("{", "").replace("}", "");

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 58 Most Valuable Professional

#2
#ManoVerse Profile Picture

#ManoVerse 42

#3
André Arnaud de Calavon Profile Picture

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

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans