Some time back, I wrote a post for retrieving an image attached to notes using OData, as now for Dynamics 365 CE, we use Web API. So, I am going to share how we can do it using Web API.
Microsoft Dynamics CRM stores all the notes and attachments in annotation entities. Most out of the box entities used to have a relationship with this entity, but while creating our custom entity we can specifically select if we want to associate our custom entity with notes or not use the following option under Communication & Collaboration. Keep in mind once you enable this option, there is no way to disable this option, but if you are not sure, if you need notes or not at the time of your entity creation it's better to leave this option un-selected, so that you can select this option after sometime if required.
NoteThe default size for notes attachment is 5 MB but if required, you can increase this limit to up to 32 MB.
Get entity image from notes
Similar to earlier versions we can upload the image to notes in Dynamics 365 CE.
Once image is attached to notes, we can retrieve it using Web API retrievemultiple request where we can query notes based on ObjectId field, we need to pass entity id field for objectid field in notes. We can using following code, in our html webresource,
Create and deploy html web resourceNow, we need to create an HTML web resource and use the above code under Text Editor.
After that, we can put this web resource to our required Entity Form and we should be able to see the first attached image in web resource after refreshing the page.
Hope it will help someone!!