Reputation: 498
I am working on CRM 2013. I have a java script web resource for my student Information system. Which takes a picture of a student and than save it as an attachment in notes.
What i am trying to do is that whenever a new picture of a student is taken, the profile should show that picture rather than the old one. Following is my OData query that return all possible attachments against the record Id. However I only need the latest attachment against my record Id.
Should I be calculating the closest time stamp? or there are other ways to do it. Can you anyone please look into this problem and suggest a feasible approach. Thanks in Advance
var temp= "/AnnotationSet?$select=DocumentBody,FileName,MimeType,ObjectId&$filter=ObjectId/Id eq guid'" + recordId + "'";
Upvotes: 3
Views: 176
Reputation: 863
Make the following change in the query:
var temp= "/AnnotationSet?$select=DocumentBody,FileName,MimeType,ObjectId&$top=1&$orderby=CreatedOn desc&$filter=ObjectId/Id eq guid'" + recordId + "'";
Upvotes: 3