Yasser Amer
Yasser Amer

Reputation: 111

Retrieve an Entity annotations using JavaScript in CRM 2011?

Can I retrieve an Entity annotations using JavaScript in CRM 2011? Or it's doable only using server side code?

Upvotes: 0

Views: 968

Answers (2)

Andrew Butenko
Andrew Butenko

Reputation: 5446

That's possible using OData and JavaScript. Other thing is why do you need it?

UPD. You can use following code as a basic for your functionality:

            var isAttached = false;

            XrmSvcToolkit.retrieveMultiple({
                entityName: "Annotation",
                odataQuery: "$select=AnnotationId&$filter=ObjectId/Id eq guid'" + Xrm.Page.data.entity.getId() + "' and IsDocument eq true",
                async: false,
                successCallback: function (results) {
                    isAttached = results.length > 0;
                },
                errorCallback: function (error) {
                    alert(error.message);
                }
            });

            if (!isAttached) {
                Xrm.Utility.alertDialog("Attach document first!");
                return;
            }

Upvotes: 1

Alex
Alex

Reputation: 23300

You can retrieve annotations querying AnnotationSet via OData.

All entities where notes are active should also have a relationship called [name of entity]_annotations that you can $expand

Upvotes: 1

Related Questions