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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Opening Annotation form using Javascript function keeps crashing

(0) ShareShare
ReportReport
Posted on by

I have created a function that opens a specific entity form and activates with a onchange event of a button. It works fine for my phonecall entity but crashes on my Annotation entity. The code is as follows:

function runShowTelephoneQuickView() {
if (Xrm.Page.data.entity.attributes.get("new_contactopgenomenvia").getValue() == "100000000") //telefoon
{
Xrm.Utility.openEntityForm("phonecall", null, {_CreateFromId: Xrm.Page.data.entity.getId(), _CreateFromType: Xrm.Page.context.getQueryStringParameters().etc, partyid: Xrm.Page.data.entity.getId(), partyname: Xrm.Page.data.entity.getPrimaryAttributeValue(), partytype: Xrm.Page.context.getQueryStringParameters().etc, pId: Xrm.Page.data.entity.getId(), pName: Xrm.Page.data.entity.getPrimaryAttributeValue(), pType: Xrm.Page.context.getQueryStringParameters().etc}, {openInNewWindow: true})
}
else if (Xrm.Page.data.entity.attributes.get("new_contactopgenomenvia").getValue() == "100000001" || Xrm.Page.data.entity.attributes.get("new_contactopgenomenvia").getValue() == "100000002")
{
Xrm.Utility.openEntityForm("annotation");
}
}


It crashes on the red part. 

The error I am getting:

DynamicsError.PNG

The error message is in dutch but it (roughly) says Error, there has been an error. Usually I get some kind of error log with what went wrong but this isn't available..

Using Dynamics 365 Online version 1612 (9.0.0.32.92) (DB 9.0.0.3292) 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Emre GULCAN Profile Picture
    2,379 on at

    Hi,

    Probably it should be OOB restriction, if you try with record ID like "Xrm.Utility.openEntityForm('annotation', 'record ID');" annotation record will be popuped but if you try "Xrm.Utility.openEntityForm('annotation');" exception throws like "The entity name doesn't exist. Please specify an existing entity name."

    5226.01.PNG

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Nicolas,

    You should add atleast minimum required parameter to open entity form.

    Try like this -

    Xrm.Utility.openEntityForm(name,id,parameters,windowOptions)

    For more information please go through below link-

    msdn.microsoft.com/.../jj602956.aspx

    Hope this helps.

    Please mark as answer if its resolve your issue.

    Thanks

    Goutam

  • Community Member Profile Picture
    on at

    I can try it (beleive I already tried it before) but according to the msdn article you posted, only the name is required (which is provided) and the others are optional..

  • Community Member Profile Picture
    on at

    @Emre GULCAN

    When specifying the javascript like this:

    var EntityID = Xrm.Page.data.entity.getId();
    Xrm.Utility.openEntityForm("annotation",EntityID);]
    

    I am getting the error: Record is not available, the requested record is not found or you don't have enough rights (which I do have).

    Might be going at this the wrong way though ;) 

  • Suggested answer
    Emre GULCAN Profile Picture
    2,379 on at

    Hi,

    your "EntityID" parameters must be annotation record's ID, not parent (for ex. account) entity ID, so "Xrm.Page.data.entity.getId();" does not work.

    As I mentioned first post, probably this is CRM's restriction. If you use "advanced find" and query to "annotation / notes", you can not use "new" button on the Advanced Find form.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    I understand seems the problem is in your above code where you are passing parameter , try with minimum parameter.

    Hope this will help definitely.

       var parameters = {};

       var windowOptions = {

           openInNewWindow: true

       };

    parameters["subject"] ="test";

    Xrm.Utility.openEntityForm("annotation", null, parameters, windowOptions);

  • Community Member Profile Picture
    on at

    @Goutam Das

    This returns the following error: Unknown entity name. The entity name does not exists.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Give some new entity name which exists in your organization. Also pass same entity parameter.

  • Suggested answer
    Emre GULCAN Profile Picture
    2,379 on at

    I think you don't care about my words :)

    When you try to open "new" annotation windows with "Xrm.Utility.openEntityForm('annotation')" Dynamics CRM throws exception because it needs "regarding object". When you create a new note on any entity form this regarding object is already exists.

    Actually I didn't sure, however this code works correctly in CRM 2016 on-prem

    var parameters = {};
    parameters["pType"] = YOUR_OBJECT_TYPE_CODE(INTEGER VALUE);
    parameters["pId"] = 'YOUR_OBJECT_RECORD_ID (GUID - STRING)';
    Xrm.Utility.openEntityForm('annotation', null, parameters);

    and also I tried this and it also works, but I prefer first example.

    window.open(Xrm.Page.context.getClientUrl() + '/notes/edit.aspx?pId=YOUR_ENTITY_RECORD_ID&pType=YOUR_ENTITY_TYPE_CODE')


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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans