Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Help with transitioning away from Xrm.Page

(0) ShareShare
ReportReport
Posted on by 2

Good afternoon,

I am testing our Dynamics environment under version 9.0 and I am finding several custom Javascripts are not working due to the use of Xrm.Page

Can someone guide me on how to proceed in converting such functions as the following?

Thank you,

Will

============================

function addTask() {
 Xrm.Utility.openEntityForm('task', null, {
  pId: Xrm.Page.data.entity.getId().replace(/{|}/g, ''),
  pType: Mscrm.EntityPropUtil.EntityTypeName2CodeMap[Xrm.Page.data.entity.getEntityName()],
  pName: Xrm.Page.getAttribute('name').getValue()
 });
}

*This post is locked for comments

  • Vikram.kshatri Profile Picture
    35 on at
    RE: Help with transitioning away from Xrm.Page

    Hi Vinoth- how to get the executionContext and formContext in HTML web resource?

  • wperkinson3 Profile Picture
    2 on at
    RE: Help with transitioning away from Xrm.Page

    Thank you sir.

  • Verified answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at
    RE: Help with transitioning away from Xrm.Page

    You have pass the PrimaryControl as parameter in ribbon command, then consume in function as usual.

    var formContext = primaryControl.getFormContext();


    [View:https://stackoverflow.com/a/48205160/7920473:750:50]

  • wperkinson3 Profile Picture
    2 on at
    RE: Help with transitioning away from Xrm.Page

    Thank you.

    The above call is being made from a button added by "Ribbon Workbench."  How does one pass the context from Ribbon Workbench?

  • Suggested answer
    Adrian Begovich Profile Picture
    1,025 Super User 2025 Season 1 on at
    RE: Help with transitioning away from Xrm.Page

    Hi wperkinson3,

    The Dynamics 365 V9 JavaScript Validator plugin in the XrmToolBox can scan your environment for JavaScript web resources to see if they are compatible with the latest version of Dynamics 365. After the scan is complete, the plugin will give you change recommendations for your JavaScript that come in useful when converting your functions.

  • Suggested answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at
    RE: Help with transitioning away from Xrm.Page

    You have to pass the Execution context from Event handler properties window. Then formContext can be extracted from it.

    function addTask(executionContext) {
    var formContext = executionContext.getFormContext(); // get formContext
     Xrm.Utility.openEntityForm('task', null, {
      pId: formContext.data.entity.getId().replace(/{|}/g, ''),
      pType: Mscrm.EntityPropUtil.EntityTypeName2CodeMap[formContext.data.entity.getEntityName()],
      pName: formContext.getAttribute('name').getValue()
     });
    }

    [View:https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/clientapi-execution-context:750:50]

    [View:https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/clientapi-form-context:750:50]

    [View:https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/walkthrough-write-your-first-client-script:750:50]

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
dkrishna Profile Picture

dkrishna 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans