Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Answered

Retrieve a List of Images from a related Entity.

Posted on by Microsoft Employee

Hi there, I need some help putting together an odata query in my javascript using REST, to get some related image data.

I have an entity named Cast.  I have a second entity named CastImages.

Each CastImage entity has a CastId.

I am writing a webresource that retrieves the list of images for me but I am struggling with the query that I need in CRM.

For a given CastId, I want to retrieve a list of the related images in the related CastImages entities.

So far I have this but I am stuck on how to retrieve the images.

//this is the Cast entity id

var regardingObjectId=window.parent.Xrm.Page.data.entity.getId();     
var entitySchemaName="CastImages";
var odataQuery = "?$select=EntityImageId&" +  
                    "$filter=ObjectId/Id eq guid'" + regardingObjectId;

   //call retrieveMultipleRecords method in SDK.REST javascript script library  
   SDK.REST.retrieveMultipleRecords(entitySchemaName, odataQuery, getPropertyImagesCallback, function (error) { alert(error.message); }, function(){});

How do I also retrieve the image data with this query?  In fact how do I retrieve the Image data at all even just for one EntityImageId?

  • Suggested answer
    Mahendar Pal Profile Picture
    Mahendar Pal 45,041 on at
    RE: Retrieve a List of Images from a related Entity.

    How you are storing your images in CastImages under notes right ?? I hope you can bring that data with your odata query using expend method which allows you to get data from related entity. refer: http://himbap.com/blog/?p=868

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Retrieve a List of Images from a related Entity.

    Thanks Drew I got it figured out in the end, thanks for your help

  • Verified answer
    Drew Poggemann Profile Picture
    Drew Poggemann 9,079 on at
    RE: Retrieve a List of Images from a related Entity.

    Sorry about that...   The only other resource that looks like it might be helpful is this:  dynamicscrmgirl.wordpress.com/.../crm-2013-javascript-update-an-entity-image-of-a-record-using-odatarest-endpoint-without-jquery

    hopefully this helps...

    Thanks,

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Retrieve a List of Images from a related Entity.

    Hi Drew and thank you for your reply.  That is retrieving images from a notes field, which I can do, and the solution unfortunately isn't using OData which I require.

    I am using the CRM SDK

  • Suggested answer
    Drew Poggemann Profile Picture
    Drew Poggemann 9,079 on at
    RE: Retrieve a List of Images from a related Entity.

    I think this old article will help...  stackoverflow.com/.../how-to-query-for-image-saved-in-records-annotation-using-javascript-in-crm-onlin

    Thanks,

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,989 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,588 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans